i've specified fetch=join for a many-to-one relationship since i always need the parent entity. this gives the expected join sql in pojo mode, but in map mode, it doesn't seem to want to use a join in the sql... anyone else seen this or know if this a known issue?
here's the mapping.
<hibernate-mapping>
<class entity-name="EmpEntity" table ="EMP">
<id name="id" type="long" column="EMP_ID">
<generator class="native"/>
</id>
<property name="ename"
type="string"
length="50"
not-null="true"
column="ENAME">
</property>
<many-to-one name="dept"
entity-name="DeptEntity"
column="DEPT_ID"
not-null="true"
fetch="join">
</many-to-one>
</class>
<class entity-name="DeptEntity" table="DEPT">
<id name="id" type="long" column="DEPT_ID">
<generator class="native"/>
</id>
<property name="dname"
type="string"
length="50"
not-null="true"
column="DNAME">
</property>
<bag name="emps" inverse="true">
<key column="DEPT_ID"/>
<one-to-many entity-name="EmpEntity"/>
</bag>
</class>
</hibernate-mapping>
the query is dynSession.createQuery("from EmpEntity").list()
the emitted sql is:
Hibernate: select empentity0_.EMP_ID as EMP1_3_, empentity0_.ENAME as ENAME3_, empentity0_.DEPT_ID as DEPT3_3_ from EMP empentity0_
Hibernate: select deptentity0_.DEPT_ID as DEPT1_4_0_, deptentity0_.DNAME as DNAME4_0_ from DEPT deptentity0_ where deptentity0_.DEPT_ID=?
Hibernate: select deptentity0_.DEPT_ID as DEPT1_4_0_, deptentity0_.DNAME as DNAME4_0_ from DEPT deptentity0_ where deptentity0_.DEPT_ID=?
Hibernate: select deptentity0_.DEPT_ID as DEPT1_4_0_, deptentity0_.DNAME as DNAME4_0_ from DEPT deptentity0_ where deptentity0_.DEPT_ID=?
thanks for any help!
|