Hello,
I have the associations as follows:
Code:
<class name="eg.FModello">
<id column="ID" name="id" type="java.lang.Long">
<generator class="sequence"/>
</id>
...
<property name="fiscal" type="java.lang.String" column="CDFISCAL" length="50"/>
<set name="terreni" inverse="false">
<key column="IDMODELLO"/>
<one-to-many class="eg.FTerreni"/>
</set>
<one-to-one name="qA" class="eg.QA" cascade="save-update" outer-join="false" constrained="false" property-ref="modello"/>
<one-to-one name="qB" class="eg.QB" cascade="save-update" outer-join="false" constrained="false" property-ref="modello"/>
<one-to-one name="qC" class="eg.QC" cascade="save-update" outer-join="false" constrained="false" property-ref="modello"/>
</class>
<class name="eg.FTerreni">
<id column="ID" name="id" type="java.lang.Long">
<generator class="sequence"/>
</id>
<property column="PRTERRENI" length="22" name="prterreni" not-null="true" type="java.lang.Long"/>
....
<many-to-one name="modello" class="eg.FModello" column="IDMODELLO" outer-join="false" cascade="save-update" />
</class>
<class name="eg.QA">
<id column="ID" name="id" type="java.lang.Long">
<generator class="sequence"/>
</id>
...
<many-to-one name="modello" class="eg.FModello" column="IDMODELLO" outer-join="false" not-null="true" />
</class>
mapping for QB, QC is the same <many-to-one> as in QA
When using criteria as follows
Code:
results = session.createCriteria(Ffamili.class)
.add(Expression.between("prterreni", min, max))
.createCriteria("modello")
.add(Expression.eq("fiscal", "0205"))
.list();
hibernate generates many select statements
Code:
...
Hibernate: select ... from GE730.FTERRENI fterreni0_ where fterreni0_.IDMODELLO=?
Hibernate: select ... from GE730.QA where QA.IDMODELLO=?
Hibernate: select ... from GE730.QB where QB.IDMODELLO=?
Hibernate: select ... from GE730.QC where QC.IDMODELLO=?
...
is there any way to do such kind of criteria without doing all those select to parent class,
i've tried using .setFetchMode() but result is the same.
Is there a better way? missing something?
In passed few years i've used Torque, must say u have created a great lib.
The only thing that i-am missing much is not allowing to access foreign key as property directly (is there ANY way?)
this has a huge performance impact on systems that (for example) uses "lookup tables" (in my case they have > 60000 rows).