Mapping two objects on same table [message #528692] |
Wed, 21 April 2010 13:52 |
Xavier Z Messages: 8 Registered: April 2010 |
Junior Member |
|
|
Hello,
I m working on a legacy database. I m encountering the following problem, there is two classes mapped into a single table. The only way to differentiate them is their id.
The Id of each of thel belongs to two differents sequences.
Example :
create table Objet ( ID number (10), value varchar2(50), value2 varchar2(50) );
create sequence seq1 start with 1 increment by 1 maxvalue 199;
create sequence seq2 start with 200 increment by 1 maxvalue 299;
I have two classes one corresponding to the value of the first sequence and the other to second one. these two classes do not belong to same hierarchy
I m using JPA 1.0 based on eclipselink 1.0.2.
I can not find a way to do this, can you help me?
X
[Updated on: Wed, 21 April 2010 13:54] Report message to a moderator
|
|
|
Re: Mapping two objects on same table [message #528939 is a reply to message #528692] |
Thu, 22 April 2010 13:18 |
|
I very odd design. You might consider having one class, or two tables.
You could map this in EclipseLink. You could set an additionalJoinExpression on the two classes where the id < 200, and id >= 200. You would need to do this in code, using a DescriptorCustomizer.
public void customize(ClassDescriptor descriptor) {
descriptor.getQueryManager().setAdditionalJoinExpression(... );
}
James : Wiki : Book : Blog : Twitter
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01829 seconds