-->
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 long the hibernate object is available after commit
PostPosted: Mon Nov 01, 2010 12:23 pm 
Newbie

Joined: Mon Nov 01, 2010 6:12 am
Posts: 1
Once I commit the transaction, can I keep referencing the hibernate object only in read-only mode.

For example :
RepositoryIntf<User> repo = new Repository<User>(User.class);
Transaction tx = HibernateUtil.getTransaction();
User u = new User();
u.setLoginId("abc");
repo.save(u);
tx.commit();


.................
Can I continue accessing this object "u" after commit or it has a life time after which object gets destroyed automatically.
................
What would be the best way if I want take the User object "u" to view.


Top
 Profile  
 
 Post subject: Re: How long the hibernate object is available after commit
PostPosted: Tue Nov 02, 2010 6:19 am 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
Object does not get destroyed at all. You can reference it as much as you want. It is how Java works. If you want to make sure object is not changed by you accidentally you may want to use "evict" on 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.