-->
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: Question: about Lazy Initialization
PostPosted: Mon Oct 13, 2003 5:58 am 
Beginner
Beginner

Joined: Fri Sep 26, 2003 2:50 am
Posts: 32
In Chapter 5.5 of reference, titled "Lazy Initlization".there is a examples as following:
Code:
s = sessions.openSession();
User u = (User) s.find("from User u where u.name=?", userName, Hibernate.STRING).get(0);
Map permissions = u.getPermissions();
s.connection().commit();
s.close();
Integer accessLevel = (Integer) permissions.get("accounts"); // Error!

Code:
The fix is to move the line that reads from the collection
to just before the commit.


How about I move the line between commit() and close?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 13, 2003 8:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
It is best practice to keep all database operations inside transaction boundaries. Having said that, if you want to confirm the behaviour of your question, you could just try it.


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.