Regular |
|
Joined: Tue Oct 07, 2003 1:13 pm Posts: 70 Location: Paris, France
|
Hibernate version:3.1b2
Mapping documents:
<class name="BuyingOffer" table="buying_offer">
<id name="id" type="java.lang.Long" column="id" >
<generator class="sequence">
<param name="sequence">buying_offer_id_seq</param>
</generator>
</id>
<many-to-one name="file" column="file_id" class="File" not-null="true"/>
<set name="houses" table="houses_buying_offers" sort="natural">
<key column="offre_achat_id"/>
<many-to-many class="House" column="house_id"/>
</set>
<property name="name" type="string" length="30" not-null="true"/>
<many-to-one name="selling" column="selling_id" unique="true" class="Selling" cascade="all"/>
</class>
Code between sessionFactory.openSession() and session.close():
List<ReportItem> result = s.createQuery("select new "+ReportItemclass.getName()+"(oa,bi) from " +
"BuyingOffer as oa join fetch oa.houses as bi join fetch oa.selling as v join fetch oa.file as d join fetch d.person " +
"where v.dateReglement is null order by d.id").list();
The generated SQL (show_sql=true):
Every entity is fetched correctly except the BuyingOffer oa ! Hibernate hits the db afterwards to hydrate the BuyingOffers oa
Can someone give me any pointers to fetch *everything* in one unique select ?
Thank you a lot for your help
Richard
|
|