Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Conditional Sequence Generator Selection
Conditional Sequence Generator Selection [message #948199] Wed, 17 October 2012 21:18 Go to next message
Scott Dudley is currently offline Scott DudleyFriend
Messages: 21
Registered: October 2012
Junior Member
I'm still a JPA neophyte but starting to get the hang of things.

Attempting to integrate JPA with a legacy RDBMS supporting both SQL Server and Oracle. For Oracle, we use sequences and for SQL, a table.

I need to be able to conditionally use one of two generators based on database type:

Oracle

@Id
@GeneratedValue(generator="generator")
@SequenceGenerator(name="generator", sequenceName="PBX_SEQ", allocationSize=1)
@Column(name="PBX_ID")
protected long pbxId;

SQL Server

@Id
@GeneratedValue(generator="generator")
@TableGenerator(name="generator", table="SEQTAB", pkColumnName="TABLENAM", valueColumnName="ID", pkColumnValue="PBX", allocationSize=1)
@Column(name="PBX_ID")
protected long pbxId;

How best would one approach this challenge?

Thanks.
Re: Conditional Sequence Generator Selection [message #964538 is a reply to message #948199] Tue, 30 October 2012 15:57 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You could use a SessionCustomizer to configure these in code on the Sesssion's login.

James : Wiki : Book : Blog : Twitter
Previous Topic:turn off all caching
Next Topic:Where is now isolation property of @cache in eclipslink 2.4.1
Goto Forum:
  


Current Time: Mon Nov 24 00:28:46 GMT 2014

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

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