Assigning a numeric sequence value to a varchar column [message #540041] |
Mon, 14 June 2010 12:28  |
Eclipse User |
|
|
|
Hi,
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 "org.hibernate.id.SequenceGenerator", but I don't know how to do something similar in EclipseLink.
Thanks in advance for your help!
Stephan
|
|
|
Re: Assigning a numeric sequence value to a varchar column [message #540874 is a reply to message #540041] |
Thu, 17 June 2010 10:19  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.23641 seconds