• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Obtaining Generated ID

 
Abiodun Adisa
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose one delegates the generating of a column to hibernate using <generator class="increment">, How do you obtain the generated value after exceuting the save method
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The save method returns the generated identifier:

http://www.hibernate.org/hib_docs/v3/api/org/hibernate/Session.html#save(java.lang.Object)

Persist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if the assigned generator is used.) This operation cascades to associated instances if the association is mapped with cascade="save-update".

Parameters:
object - a transient instance of a persistent class
Returns:
the generated identifier
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic