-->
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.  [ 3 posts ] 
Author Message
 Post subject: Get the identity (PK) of a newer inserted object
PostPosted: Sat Apr 04, 2009 1:29 am 
Newbie

Joined: Sat Aug 05, 2006 3:01 pm
Posts: 4
Hi,

Quick question; how do I get the identity (PK) of a newer inserted object?
In the mapping file the object identity is defined as <generator class="identity" />.

Thanks a lot,
Mike


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 04, 2009 2:16 am 
Newbie

Joined: Tue Aug 19, 2008 9:30 am
Posts: 10
well, if you save it via session.save( Object o ) it is returned to you, but cant you just call session.saveOrUpdate( Object o ) and then call the PK-getter of the object?

regards,
Stephan


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 04, 2009 1:33 pm 
Newbie

Joined: Sat Aug 05, 2006 3:01 pm
Posts: 4
That's exactly what i figured out.
Once I call the SaveOrUpdate() method the object ID property gets populated, so i can use it from there.

Thanks a lot!


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