-->
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: How to Mapping a Collection of embedded Objects Question
PostPosted: Thu Nov 12, 2009 12:07 am 
Regular
Regular

Joined: Tue Jul 29, 2008 4:15 pm
Posts: 62
Location: Dallas, TX US
Hello.

I have been reading the Java Persistence with Hibernate book and on page 258 it describes how to Map a collection of embedded objects. I've been able to implement this mapping successfully. However when I try to access the mapped collection of embedded objects, I get the following error:
Code:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: Transaction.states, no session or session was closed
Now I understand why this is happening; as my Transaction is detached and Transaction.states have not been initialized; but I thought since these states are embedded in the Transaction class they would be automatically populated when I get the Transaction from the database, via a session.get(type, id).

Any help with this is welcomed and appreciated.

Thanks!

Tonté

_________________
pouncilt


Top
 Profile  
 
 Post subject: Re: How to Mapping a Collection of embedded Objects Question
PostPosted: Thu Nov 12, 2009 5:57 pm 
Regular
Regular

Joined: Tue Jul 29, 2008 4:15 pm
Posts: 62
Location: Dallas, TX US
I finally got this resolved by added the fetch = FetchType.EAGER property to the @CollectionOfElements. The funny thing is the book did not indicate this.

Huh, go figure.

Tonté

_________________
pouncilt


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.