Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Assigning a numeric sequence value to a varchar column
Assigning a numeric sequence value to a varchar column [message #540041] Mon, 14 June 2010 16:28 Go to next message
Stephan Vollmer is currently offline Stephan VollmerFriend
Messages: 2
Registered: June 2010
Junior Member

I have to switch from Hibernate to EclipseLink 2.0.x and have the following problem:

We use a legacy Oracle DB and the primary keys are numbers that are stored in varchar2 columns padded with zeroes. Example: 0000012345

The primary keys are generated by a sequence that returns numeric values.

The problem is the datatype mismatch: When I declare the Java type as String, then I get this error: "Invalid type specified for identity column 'REQUEST_ID'. The only valid types for identity columns are BIGINT, INT and SMALLINT."

Is there any solution for this problem in EclipseLink or plain JPA2? In Hibernate, I use a custom "", but I don't know how to do something similar in EclipseLink.

Thanks in advance for your help!
Re: Assigning a numeric sequence value to a varchar column [message #540874 is a reply to message #540041] Thu, 17 June 2010 14:19 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Could you include the stack trace for the error. It does not sound like and Oracle error, are you sure you are using the Oracle database (there are no identity columns on Oracle, nor BIGINT, INT, SMALLINT..., Oracle normally auto converts types without issues)?

EclipseLink supports custom sequence generation using its Sequence classes (org.eclipse.persistence.sequencing). You can register your own custom Sequence subclass on the EclipseLink Session's DatabaseLogin using a SessionCustomizer.

James : Wiki : Book : Blog : Twitter
Previous Topic:Readonly ManyToMany mapping?
Next Topic:@PreUpdate not called with AspectJ
Goto Forum:

Current Time: Sat Nov 17 12:38:33 GMT 2018

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

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

Back to the top