Je migre un projet de jboss7 vers wildfly10. La chose étrange est que la requête générée dans jboss est différente dans wildfly10, ce qui provoque la modification de la structure des tables, mais cela n'est pas attendu.Problème d'héritage JPA, pourquoi la requête générée est différente entre wildfly10 et jboss7
public class BaseAnnotation implements Serializable {
private static final long serialVersionUID = 6636704943305921427L;
}
@Entity
@Table(name="one")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
public class oneBaseAnnotation extends BaseAnnotation {
@Id
@GeneratedValue(generator = "baseAnnotationSequencer")
@SequenceGenerator(name = "baseAnnotationSequencer", sequenceName = "BASEANNOTATION_SEQ")
private Long id;
private String annotationType;
.....
}
@Entity
public class TwoStructureAnnotation extends oneBaseAnnotation {
private static final long serialVersionUID = -5838272604038154615L;
@OneToMany
@JoinTable(name= "CSA_CS")
private List<TwoStructure> twoStructures = new ArrayList<TwoStructure>();
public TwoStructureAnnotation() {
setAnnotationType("Two Structure");
}
.....
}
public class..... {
protected List<T> createQuery(int first, int pageSize,
List<SortMeta> multiSortMeta, Map<String, String> filters,
String joinField) {
// Setup
CriteriaBuilder cb = getObjectEntityManager().getCriteriaBuilder();
CriteriaQuery<T> criteria = (CriteriaQuery<T>) cb.createQuery();
Root<A> annotationRoot = criteria.from(TwoStructureAnnotation.class);
ListJoin<A, T> joinRoot = annotationRoot.joinList("twosStructures");
Predicate restrictions = cb.conjunction();
// Filter
filters.putAll(this.getBaseFilter());
restrictions = cb.and(restrictions,
createGlobalFilter(filters, joinRoot, cb));
restrictions = cb.and(restrictions,
cb.equal(annotationRoot, annotation));
...
// Query creation
criteria.where(restrictions);
criteria.select(joinRoot);
// Restrict Returns
TypedQuery<T> returnQuery = getObjectEntityManager().createQuery(
criteria);
returnQuery.setFirstResult(first);
returnQuery.setMaxResults(pageSize);
List<T> results = returnQuery.getResultList();
....}
La requête ci-dessous, les différents que la clé dans la inner join
sur la table CSA_CS. Je n'ai aucune idée pourquoi, s'il vous plaît me suggérer, merci.
--En Jboss7
select * from
(select
crystalstr2_.id as id1_43_,
crystalstr2_.pdbEntry_id as pdbEntry_id3_43_,
crystalstr2_.title as title2_43_
from
ONE crystalstr0_
inner join
CSA_CS crystalstr1_
on crystalstr0_.id=crystalstr1_.ONE_id
inner join
TwoStructure crystalstr2_
on crystalstr1_.crystalStructures_id=crystalstr2_.id
where
crystalstr0_.DTYPE='TwoStructureAnnotation'
and 1=1
and 1=1
and crystalstr0_.id=?)
where
rownum <= ?
--- Dans wildfly10
select
*
from
(select
crystalstr2_.id as id1_36_,
crystalstr2_.pdbEntry_id as pdbEntry_id3_36_,
crystalstr2_.title as title2_36_
from
ONE crystalstr0_
inner join
CSA_CS crystalstr1_
on crystalstr0_.id=crystalstr1_.TWOStructureAnnotation_id
inner join
TwoStructure crystalstr2_
on crystalstr1_.crystalStructures_id=crystalstr2_.id
where
crystalstr0_.DTYPE='TwoStructureAnnotation'
and 1=1
and 1=1
and crystalstr0_.id=?)
where
rownum <= ?
Tables:
table-TWOSTRUCTURE
ID
TITLE
table-CSA_CS
ONE_ID
CRYSTALSTRUCTURES_ID
table-ONE
DTYPE
ID
ANNOTATIONTYPE
merci de répondre. le problème en ce moment est le nom d'identification de la clé dans un serveur différent a un nom de colonne différent. la jointure interne est la même entre 2 serveurs. – fromdw