jQuery in Action, 2nd edition
The moose likes Object Relational Mapping and the fly likes Auto ID generation strategy in JPA Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "Auto ID generation strategy in JPA" Watch "Auto ID generation strategy in JPA" New topic
Author

Auto ID generation strategy in JPA

bagaria kushal
Greenhorn

Joined: Mar 29, 2011
Posts: 19
If we specify id generation strategy as AUTO, the persistence provider chooses one of the following strategies :-

- Table
-Sequence
-Identity

My question is on what basis or criteria does the persistence provider decides which strategy to be used?
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 550
This depends on the provider.

By default EclipseLink uses TABLE sequencing. This is because IDENTITY and SEQUENCE require database support, so TABLE is the most platform independent.

See,
http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Entities/Ids/GeneratedValue#.40GeneratedValue


TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Auto ID generation strategy in JPA
 
Similar Threads
autogenerated keys
Assigned id generator and Save Method
sequence generator with mysql
Primary Key Autogeneration for InheritenceType. TABLE_PER_CLASS
Question on Id Generation Strategies