Programming Tutorials

Assigned identifiers in Hibernate

By: Dorris in Hibernate Tutorials on 2011-01-01  

If you want the application to assign identifiers, as opposed to having Hibernate generate them, you can use the assigned generator. This special generator uses the identifier value already assigned to the object's identifier property. The generator is used when the primary key is a natural key instead of a surrogate key. This is the default behavior if you do not specify @GeneratedValue nor <generator> elements.

The assigned generator makes Hibernate use unsaved-value="undefined". This forces Hibernate to go to the database to determine if an instance is transient or detached, unless there is a version or timestamp property, or you define Interceptor.isUnsaved().






Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Hibernate )

Latest Articles (in Hibernate)