• Post Reply Bookmark Topic Watch Topic
  • New Topic

hibernate save return id

 
Jehan Jaleel
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
If my database auto-generates the primary key as an identity column, is it possible to have Hibernate return this when I call save off the session object?

Thanks for any help,
Jehan
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate's Session.save returns the id. look in the Javadoc

http://www.hibernate.org/hib_docs/v3/api/

Mark
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!