I am facing a issue with the query generated by hibernate to load from database.
SELECT THIS_.ID AS ID25_1_,
THIS_.NAME AS NAME25_1_,
OFFICES2_.LEGAL_ENTITY_ID AS LEGAL3_3_,
OFFICES2_.ID AS ID3_,
OFFICES2_.ID AS ID27_0_, OFFICES2_.NAME AS NAME27_0_
FROM CUSTOMER_MASTER.LEGAL_ENTITIES THIS_
LEFT OUTER JOIN CUSTOMER_MASTER.OFFICES OFFICES2_ ON THIS_.ID = OFFICES2_.LEGAL_ENTITY_ID
Why is hibernate generating query with duplicate reference to offices2_.id ?
My hbm file for legal_entities table is -
Code:
<hibernate-mapping>
<class name="LegalEntity" table="LEGAL_ENTITIES" schema="CM" lazy="false">
<id name="id" type="long">
<column name="ID" precision="22" scale="0"/>
<generator class="sequence">
<param name="sequence">legal_entities_seq</param>
</generator>
</id>
<property name="name" type="string">
<column name="NAME"/>
</property>
<bag name="offices" cascade="none" fetch="join" inverse="true" lazy="false" >
<key column="LEGAL_ENTITY_ID"/>
<one-to-many class="Office"/>
</bag>
</class>
</hibernate-mapping>
And hbm for office is -
Code:
<hibernate-mapping>
<class name="Office" table="OFFICES" schema="CM" lazy="false">
<id name="id" type="long">
<column name="ID" precision="22" scale="0"/>
<generator class="sequence">
<param name="sequence">offices_seq</param>
</generator>
</id>
<property name="name" type="string">
<column name="NAME"/>
</property>
</class>
</hibernate-mapping>