2017-02-27 31 views
0

我正在將項目從jboss7遷移到wildfly10。奇怪的是,jboss中生成的查詢在wildfly10中不同,導致表結構必須更改,但這不是預期的結果。JPA繼承問題,爲什麼生成的查詢在wildfly10和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(); 

    ....} 

查詢下面,不同的是表中的鍵CSA_CS上的inner join。我不知道爲什麼,請給我建議,謝謝。

--in Jboss7

​​

---在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 <= ? 

表:

table-TWOSTRUCTURE 
ID 
TITLE 

table-CSA_CS 
ONE_ID 
CRYSTALSTRUCTURES_ID 

table-ONE 
DTYPE 
ID 
ANNOTATIONTYPE 

回答

0

JBoss7於冬眠4.x和wildfly 10個一般冬眠5.在hibernate 5,Oracle實現了'內連接'。如果你使用Oracle10gDialect,那麼 Oracle10gDialect增加了對ANSI連接的支持。子類(例如Oracle12cDialect)繼承此功能。

+0

謝謝你的回覆。現在的問題是不同服務器中的密鑰ID名稱具有不同的列名稱。兩個服務器之間的內部連接相同。 – fromdw