-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: lazy loading? or something else? dont get the sets!
PostPosted: Mon Sep 07, 2009 6:35 am 
Newbie

Joined: Mon Sep 07, 2009 5:35 am
Posts: 4
Hi, I have the following configuaration (see below) with country having many operators and I need to write a method (in the countryDAO) which gets all the countries without getting its partners! how do I do that????

Country
Code:
<hibernate-mapping>
   <class name="ch.orange.rps_ws.domain.Country" table="Country">
      <id name="id" column="country_id">
         <generator class="native"/>
      </id>
      <property name="country_fr" column="country_fr"/>
      <property name="country_it" column="country_it"/>
      <property name="country_de" column="country_de"/>
      <property name="country_en" column="country_en"/>
      
      <set name="partners" table="partner_in_country">
           <key column="country_id"/>
           <many-to-many column="partner_id" class="ch.orange.rps_ws.domain.Partner"/>
          </set>
          
   </class>
   
</hibernate-mapping>


Partner
Code:
<hibernate-mapping>
   <class name="ch.orange.rps_ws.domain.Partner" table="Partner">
      <id name="id" column="partner_id">
         <generator class="assigned"/>
      </id>
      <property name="official_name" column="official_name"/>
      <property name="network_name" column="network_name"/>
      <property name="handset_display" column="handset_display"/>
      <property name="web_address" column="web_address"/>
      <property name="map_url" column="map_url"/>
      <property name="map_code_2g" column="map_code_2g"/>
      <property name="map_code_3g" column="map_code_3g"/>
      <property name="visible" column="visible"/>
      
      <set name="services" table="partner_has_service">
           <key column="partner_id"/>
           <many-to-many column="service_id" class="ch.orange.rps_ws.domain.Service"/>
          </set>
   </class>
</hibernate-mapping>


my current dao is defined as follows:
Code:
public Collection<Country> loadAll()
   {
      Query q = getSession().createQuery("from Country");
      Collection<Country> objects = (Collection<Country>) q.list();
      
      return objects;
   }


but when I use it, I get also the contents of its partner set!


Top
 Profile  
 
 Post subject: Re: lazy loading? or something else? dont get the sets!
PostPosted: Mon Sep 07, 2009 7:39 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
You can just set the fectch type to lazy.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Re: lazy loading? or something else? dont get the sets!
PostPosted: Mon Sep 07, 2009 7:45 am 
Newbie

Joined: Mon Sep 07, 2009 5:35 am
Posts: 4
Cameron McKenzie wrote:
You can just set the fectch type to lazy.

and where should I add it? I tired like this but it doesn't work:

in the country.hbm.xml
Code:
<set name="partners" table="partner_in_country" lazy="true">
           <key column="country_id"/>
           <many-to-many column="partner_id" class="ch.orange.rps_ws.domain.Partner"/>
          </set>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.