-->
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: retrieve the newly inserted record back after saveOrUpdate()
PostPosted: Wed Sep 24, 2008 8:56 am 
Beginner
Beginner

Joined: Thu Oct 05, 2006 4:00 pm
Posts: 22
just wonder, how can I get the newly inserted record back, the primary key (ID) is generated by a sequence. e.g like this

<id name="id" type="long" column="order_id" unsaved-value="null" access="field">
<generator class="sequence">
<param name="sequence">order_id_seq</param>
</generator>
</id>

Thanks.


Top
 Profile  
 
 Post subject: bump it up, I mean, how do I know the ID
PostPosted: Wed Sep 24, 2008 10:03 pm 
Beginner
Beginner

Joined: Thu Oct 05, 2006 4:00 pm
Posts: 22
how do I know the ID for the newly inserted record?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 25, 2008 1:46 am 
Beginner
Beginner

Joined: Wed Sep 24, 2008 5:44 pm
Posts: 34
you should still have a reference to the object.

you call saveOrUpdate(object)
then you can call object.getId();


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.