Why does my collection (misturaStocks) get loaded in:
res = session.find("from pt.comseal.arsol.vo.Mistura as m " +
"left join fetch m.misturaStocks " +
"where m.userId= '" + user + "'");
and not in:
Mistura m = (Mistura)session.get(Mistura.class, mistura.getId());
Hibernate.initialize(m.getMisturaStocks());
-----------------------------------------------------
Mapping file (generated with Middlegen R3)
-----------------------------------------------------
Mistura
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="vo.Mistura"
table="mistura"
>
<id
name="id"
type="long"
column="id"
>
<generator class="increment" />
</id>
<property
name="userId"
type="java.lang.String"
column="user_id"
not-null="true"
length="10"
/>
<!-- associations -->
<!-- bi-directional one-to-many association to MisturaStock -->
<set
name="misturaStocks"
lazy="true"
inverse="true"
>
<key>
<column name="mistura_fk" />
</key>
<one-to-many
class="vo.MisturaStock"
/>
</set>
</class>
</hibernate-mapping>