Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.05
Mapping documents:
<hibernate-mapping default-lazy="true">
<class name="com.coginfo.kf.bean.Modalita" table="KFT_MODALITA" select-before-update="true">
<meta attribute="class-description">Modalita</meta>
<composite-id name="id" class="com.coginfo.kf.bean.ModalitaPk">
<key-many-to-one name="codintdmn" class="com.coginfo.kf.bean.Dominio"/>
<key-property name="codint" length="10"/>
</composite-id>
<property name="cafdsc" type="string">
<column name="cafdsc" length="1000" sql-type="string" not-null="true"/>
</property>
<property name="codtip" type="integer">
<column name="codtip" length="1" sql-type="integer" not-null="true"/>
</property>
<many-to-one class="com.coginfo.kf.bean.ValoreModalita" name="codintvalmod" column="codintvalmod" fetch="join" lazy="true"/>
<set name="modalitaRuolo" lazy="true" cascade="none">
<key>
<column name="codintdmn"/>
<column name="codintmod"/>
</key>
<one-to-many class="com.coginfo.kf.bean.ModalitaRuolo"/>
</set>
</class>
<query name="find.modalita"><![CDATA[
from Modalita mod order by mod.cafdsc ]]>
</query>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
session.createCriteria(Modalita.class);
The generated SQL (show_sql=true):
1-
select modalita0_.codintdmn as codintdmn, modalita0_.codint as codint, modalita0_.cafdsc as cafdsc11_, modalita0_.codtip as codtip11_, modalita0_.codintvalmod as codintva5_11_ from KFT_MODALITA modalita0_
2-
select valoremoda0_.codint as codint0_, valoremoda0_.dscvalmod as dscvalmod13_0_, valoremoda0_.codtipmod as codtipmod13_0_ from KFT_VALORE_MODALITA valoremoda0_ where valoremoda0_.codint=?
The problem is: why 2 queries and not only 1 with outer-join??
thanks