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 12:28 Go to next message
Stephan Vollmer is currently offline Stephan Vollmer
Messages: 2
Registered: June 2010
Junior Member
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 Go to previous message
James Sutherland is currently offline James Sutherland
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: Thu Apr 24 14:43:43 EDT 2014

Powered by FUDForum. Page generated in 0.03065 seconds