Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » @GeneratedValue(strategy=GenerationType.AUTO)(How to configure the default for EclipseLink?)
@GeneratedValue(strategy=GenerationType.AUTO) [message #692531] Mon, 04 July 2011 16:58 Go to next message
Juergen Kissner is currently offline Juergen Kissner
Messages: 25
Registered: March 2011
Junior Member
I have been playing with @GeneratedValue(strategy=GenerationType.AUTO) on various database platforms.

The HowTo on primary key generation (wiki.eclipse.org/EclipseLink/Examples/JPA/PrimaryKey) says:
"Typically, EclipseLink picks TABLE as the strategy, since it is the most portable strategy."

The adverb "Typically" seems to indicate that the strategy EclipseLink picks for GenerationType.AUTO can be configured.

Is there a way to influence EclipseLink's choice in such a way that the strategy for GenerationType.AUTO depends on the selected database platform?

--Juergen
Re: @GeneratedValue(strategy=GenerationType.AUTO) [message #698461 is a reply to message #692531] Tue, 19 July 2011 14:18 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

EclipseLink defines a Map of Sequence objects on the EclipseLink Session's DatabaseLogin.

The login defines a DefaultSequence which could be set using a SessionCustomizer, or in your DatabasePlatform's initialization.
I think JPA AUTO will use a Sequence named "SEQ_GEN" by default, so you could define a Sequence with this name.
There is also a method in DatabasePlatform createPlatformDefaultSequence(), which you could potentially override to default to another type of sequencing.


James : Wiki : Book : Blog : Twitter
(no subject) [message #698492 is a reply to message #692531] Tue, 19 July 2011 14:18 Go to previous message
James is currently offline James
Messages: 272
Registered: July 2009
Senior Member
EclipseLink defines a Map of Sequence objects on the EclipseLink Session's DatabaseLogin.

The login defines a DefaultSequence which could be set using a SessionCustomizer, or in your DatabasePlatform's initialization.
I think JPA AUTO will use a Sequence named "SEQ_GEN" by default, so you could define a Sequence with this name.
There is also a method in DatabasePlatform createPlatformDefaultSequence(), which you could potentially override to default to another type of sequencing.

--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/
Previous Topic:EclipseLink 2.3 PL/SQL enhancements available for DB2?
Next Topic:Eclipselink.ddl-generation : drop-and-create-tables don't drop tables
Goto Forum:
  


Current Time: Tue Sep 16 04:56:07 GMT 2014

Powered by FUDForum. Page generated in 0.02258 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software