-->
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: Get saved object after save
PostPosted: Fri Dec 23, 2005 12:15 am 
Beginner
Beginner

Joined: Sun Oct 16, 2005 3:07 am
Posts: 33
Location: Sydney
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3

Whats the simplest way of getting the Object thats just been saved back (immediately after save)? I'm using Oracle 8 and the id is assigned using sequences

Cheers


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 23, 2005 2:14 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi

session.save(obj);
session.flush();
session.load(obj);

I think this is the normal way!!!!!!!!!!!!!!!!!

_________________
RamnathN
Software Engineer


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 23, 2005 3:21 am 
Regular
Regular

Joined: Tue Nov 16, 2004 6:36 pm
Posts: 62
Location: Zürich
ramnath wrote:
Hi

session.save(obj);
session.flush();
session.load(obj);

I think this is the normal way!!!!!!!!!!!!!!!!!


I would session.evict(obj) the object after session.flush() to ensure the object is reread (is no longer in the 1st level cache).


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 23, 2005 4:02 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
session.refresh(o);

_________________
Max
Don't forget to rate


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.