-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate.initialize
PostPosted: Mon Feb 02, 2004 1:29 pm 
Newbie

Joined: Thu Dec 18, 2003 4:13 am
Posts: 19
Hello,

I have an object 'object' mapped to the database with Hibernate. This object has a property, 'property' contains a set 'elements' which is declared as lazy initialized.

This means that when I load the object from our DAO, the set is not initialized.

Later on, when i want to work with it within the presentation layer, I first call my DAO (behind EJBs) and call the following method:

Hibenernate.initialize(object.getProperty().getElements());

H


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 02, 2004 1:31 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You can reassociate the object with the session using Session.lock(object, LockMode.NONE)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 02, 2004 2:07 pm 
Newbie

Joined: Thu Dec 18, 2003 4:13 am
Posts: 19
ouch ! it fails too...

i added the following line before calling Hibernate.initialize(objet.getProperty().getElements()) :

session.lock(object, LockMode.NONE);

and now i get the following error :
net.sf.hibernate.TransientObjectException : attemped to lock a transient instance


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 02, 2004 2:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Use a recent version of Hibernate (supported since 2.1)


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