-->
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 Identifier after commit
PostPosted: Fri Jan 16, 2004 7:24 pm 
Beginner
Beginner

Joined: Fri Jan 16, 2004 4:58 pm
Posts: 37
Forgive me if this has been asked before. I searched the forums, FAQ, and Google but could not find an answer.

I have a MySQL database with an autogenerated ID column. I am using the "Identity" class in my O/R mapping. Everything works great.

I need to return that Autogenerated ID number back to my app. Is there a fancy Hibernate way of doing this or do I have to go back with SQL to get this information.

Thanks.

Gregg


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 8:19 pm 
Regular
Regular

Joined: Wed Jan 07, 2004 5:16 pm
Posts: 65
Location: CA, USA
The generated id is automagically copied into the id property in the object you just persisted (according to your mapping).

There is no need for an explicit step to go an retrieve the id - it is done for you.

For example if you persisted some instance of an object and it has an 'id' property, then you just need to call it's getter:
Code:
someObject.getId()


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 9:33 pm 
Beginner
Beginner

Joined: Fri Jan 16, 2004 4:58 pm
Posts: 37
Oh dear. Duh! Thanks. I feel stupid. :)


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.