Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Conditional Sequence Generator Selection

mrdudleyOct 19 2012 — edited Nov 7 2012
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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 5 2012
Added on Oct 19 2012
4 comments
756 views