Hallo,
this is a extract of ower classes:
Code:
@Entity
@Table(name = "KEYWORD")
public class Keyword extends StrongEntity {
@ManyToMany(fetch = FetchType.EAGER, mappedBy = "keywords")
@Where(clause = "RECORDSTATUS_ID <> 5")
private Set<Articletype> articleTypes;
}
@Entity
@Table(name = "ARTICLETYPE")
public class Articletype extends TranslatableEntity implements IArticletype, ISortable, IMementoOriginator {
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "ARTICLETYPE_KEYWORD", joinColumns = { @JoinColumn(name = "ARTICLETYPE_ID") }, inverseJoinColumns = { @JoinColumn(name = "KEYWORD_ID") })
@Where(clause = "RECORDSTATUS_ID <> 5")
private Set<Keyword> keywords;
}
When we load an entiy keyword with EntityManager.find(Keyword.class, keyword_id), hibernate generates following sql:
Quote:
select keyword0_.KEYWORD_ID as KEYWORD_ID1_265_0_, keyword0_.LAST_MODIFIED as LAST_MODIFIED2_265_0_, keyword0_.RECORDSTATUS_ID as RECORDSTATUS_ID3_265_0_, keyword0_.LOCKED as LOCKED4_265_0_, articletyp1_.KEYWORD_ID as KEYWORD_ID2_265_1_, articletyp2_.ARTICLETYPE_ID as ARTICLETYPE_ID1_49_1_, articletyp2_.ARTICLETYPE_ID as ARTICLETYPE_ID1_43_2_, articletyp2_.LAST_MODIFIED as LAST_MODIFIED2_43_2_, articletyp2_.RECORDSTATUS_ID as RECORDSTATUS_ID3_43_2_, articletyp2_.NAME as NAME4_43_2_, articletyp2_.NAME_ID as NAME_ID5_43_2_, articletyp2_.ARTICLETYPEGROUP_ID as ARTICLETYPEGROUP_13_43_2_, articletyp2_.ASSISTENT as ASSISTENT6_43_2_, articletyp2_.ASSISTENTNAME as ASSISTENTNAME7_43_2_, articletyp2_.ASSISTENTNAME_ID as ASSISTENTNAME_ID8_43_2_, articletyp2_.DEVICE as DEVICE9_43_2_, articletyp2_.EXTERNAL_ID as EXTERNAL_ID10_43_2_, articletyp2_.PRODUCTNAME as PRODUCTNAME11_43_2_, articletyp2_.SORTVALUE as SORTVALUE12_43_2_, names3_.NAME_ID as NAME_ID2_43_3_, names3_.LANGUAGE_ID as LANGUAGE_ID1_279_3_, names3_.NAME_ID as NAME_ID2_279_3_, names3_.LANGUAGE_ID as formula57_3_, names3_.LANGUAGE_ID as LANGUAGE_ID1_279_4_, names3_.NAME_ID as NAME_ID2_279_4_, names3_.LAST_MODIFIED as LAST_MODIFIED3_279_4_, names3_.RECORDSTATUS_ID as RECORDSTATUS_ID4_279_4_, names3_.ABBREVIATION as ABBREVIATION5_279_4_, names3_.DESCRIPTION as DESCRIPTION6_279_4_, names3_.NAME as NAME7_279_4_, articletyp4_.ARTICLETYPEGROUP_ID as ARTICLETYPEGROUP_I1_44_5_, articletyp4_.LAST_MODIFIED as LAST_MODIFIED2_44_5_, articletyp4_.RECORDSTATUS_ID as RECORDSTATUS_ID3_44_5_, articletyp4_.NAME as NAME4_44_5_, articletyp4_.NAME_ID as NAME_ID5_44_5_, articletyp4_.SORTVALUE as SORTVALUE6_44_5_, translatio5_.KEYWORD_ID as KEYWORD_ID4_265_6_, translatio5_.TRANSLATION_ID as TRANSLATION_ID1_266_6_, translatio5_.TRANSLATION_ID as TRANSLATION_ID1_266_7_, translatio5_.LAST_MODIFIED as LAST_MODIFIED2_266_7_, translatio5_.RECORDSTATUS_ID as RECORDSTATUS_ID3_266_7_, translatio5_.KEYWORD_ID as KEYWORD_ID4_266_7_, translatio5_.LANGUAGE_ID as LANGUAGE_ID6_266_7_, translatio5_.NAME as NAME5_266_7_, language6_.LANGUAGE_ID as LANGUAGE_ID1_268_8_, language6_.LAST_MODIFIED as LAST_MODIFIED2_268_8_, language6_.RECORDSTATUS_ID as RECORDSTATUS_ID3_268_8_, language6_.NAME as NAME4_268_8_, language6_.NAME_ID as NAME_ID5_268_8_, language6_.FALLBACK_LANGUAGE_ID as FALLBACK_LANGUAGE_9_268_8_, language6_.ISO639_1 as ISO6_268_8_, language6_.ISO639_3 as ISO7_268_8_, language6_.SPELL_CHECKED as SPELL_CHECKED8_268_8_, language7_.LANGUAGE_ID as LANGUAGE_ID1_268_9_, language7_.LAST_MODIFIED as LAST_MODIFIED2_268_9_, language7_.RECORDSTATUS_ID as RECORDSTATUS_ID3_268_9_, language7_.NAME as NAME4_268_9_, language7_.NAME_ID as NAME_ID5_268_9_, language7_.FALLBACK_LANGUAGE_ID as FALLBACK_LANGUAGE_9_268_9_, language7_.ISO639_1 as ISO6_268_9_, language7_.ISO639_3 as ISO7_268_9_, language7_.SPELL_CHECKED as SPELL_CHECKED8_268_9_ from KEYWORD keyword0_ left outer join ARTICLETYPE_KEYWORD articletyp1_ on keyword0_.KEYWORD_ID=articletyp1_.KEYWORD_ID left outer join ARTICLETYPE articletyp2_ on articletyp1_.ARTICLETYPE_ID=articletyp2_.ARTICLETYPE_ID left outer join NAME names3_ on articletyp2_.NAME_ID=names3_.NAME_ID left outer join ARTICLETYPEGROUP articletyp4_ on articletyp2_.ARTICLETYPEGROUP_ID=articletyp4_.ARTICLETYPEGROUP_ID left outer join KEYWORDTRANSLATION translatio5_ on keyword0_.KEYWORD_ID=translatio5_.KEYWORD_ID and ( translatio5_.RECORDSTATUS_ID <> 5) left outer join LANGUAGE language6_ on translatio5_.LANGUAGE_ID=language6_.LANGUAGE_ID left outer join LANGUAGE language7_ on language6_.FALLBACK_LANGUAGE_ID=language7_.LANGUAGE_ID where (articletyp2_.RECORDSTATUS_ID <> 5) and keyword0_.KEYWORD_ID=?
The restriction on
Quote:
where (articletyp2_.RECORDSTATUS_ID <> 5) and keyword0_.KEYWORD_ID=?
is an unexpected behaviour for us. We expected, that the where clause is part of the left outer join, and not of the general where clause.
Is our expectation wrong?
It was working as exptected, with hibernate-core-4.2.0.CR1.jar on JBoss 7.2, but now with hibernate-core-4.3.10.Final.jar on Wildfly 9.0.2 we have the above behaviour. So there was a change between these versions.