-->
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: Generated ID after persistance.
PostPosted: Sat Mar 19, 2011 6:16 am 
Newbie

Joined: Sat Mar 19, 2011 6:12 am
Posts: 2
Hi.
I want to know how can I figure out the ID generated by the database after session.save() method.
I have a class that contains several fields, and I want the ID field to be populated after perssisting the object.
Is there a natural way for that to be done ?


Top
 Profile  
 
 Post subject: Re: Generated ID after persistance.
PostPosted: Sun Mar 20, 2011 8:00 am 
Beginner
Beginner

Joined: Mon Nov 15, 2010 10:39 am
Posts: 27
I'm not really sure what you are asking, but hibernate id-field could perhaps be used. If you map the property as

<id name="id" column="id">
<generator class="native"/>
</id>

then hibernate will populate this column with a fresh id upon persisting the object. The id can be found using the getter from the persistence class.


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.