-->
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.  [ 2 posts ] 
Author Message
 Post subject: Unable to Lazy Initialize a HashSet
PostPosted: Fri Nov 28, 2008 7:07 pm 
Beginner
Beginner

Joined: Sun Jan 16, 2005 5:45 pm
Posts: 24
Location: Atlanta
Hi, I am having an odd problem where I cannot lazy initialize a collection.

In the DAO have the following method:
Code:
   public AirlineImpl readAirline(String pCode, Set<String> pReadOpts) throws NotFoundException {
      AirlineImpl airline;
      try {
         airline = (AirlineImpl) em.createQuery("Select a From AirlineImpl a WHERE a.code = " +
               "'" + pCode + "'").getSingleResult();
         
         // Now lazy load requested objects
         
         if (pReadOpts.contains(AirlinePersistenceConstants.AirlineContact)) {
            Hibernate.initialize(airline.getAirlineContact()); // Lazy load contact
         }
            
         if (pReadOpts.contains(AirlinePersistenceConstants.AirlineUnitsOfMeasure)) {
            Hibernate.initialize(airline.getAirlineUnitsOfMeasure()); // Lazy load contact
         }
         
         if (pReadOpts.contains(AirlinePersistenceConstants.AirlineLoadCodes)) {
            Hibernate.initialize(airline.getAirlineLoadInformationCodes());
            Set<AirlineLoadInformationCode> d = airline.getAirlineLoadInformationCodes(); // Lazy load contact
         }
         
         em.flush();

         
      } catch (NoResultException e) {
         throw new NotFoundException();
      }
      return airline;
   }


The code in question is:



Code:
         if (pReadOpts.contains(AirlinePersistenceConstants.AirlineLoadCodes)) {
            Hibernate.initialize(airline.getAirlineLoadInformationCodes());
            Set<AirlineLoadInformationCode> d = airline.getAirlineLoadInformationCodes(); // Lazy load contact
         }


No matter what I do, the object type both before and after this code is PersistentSet. How do I get this object initalized correctly? It should be a HashSet.

Code:
      <set name="AirlineLoadInformationCodes" lazy="true" cascade="save-update,lock" inverse="true">
         <key column="airlineid" not-null="true"/>
         <one-to-many class="com.sita.wab.entities.AirlineLoadInformationCodeImpl"/>
      </set>


I'm sure it is a simple problem.

Thanks in advance!

Paul


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 29, 2008 11:01 am 
Beginner
Beginner

Joined: Sun Jan 16, 2005 5:45 pm
Posts: 24
Location: Atlanta
Please disregard. The problem was unrelated to Hibernate.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.