Hi,
I have the following problem. I have a mapped superclass:
@MappedSuperclass
public class MySuperClass {
@Version
private long version;
private String foo;
private String bar;
// getter/setter omitted
}
and two entities, the second of which uses a shared primary key:
@Entity
public class MainEntity extends MySuperClass {
@Id @GeneratedValue
private Long id;
@OneToOne(mappedBy="main")
private SecondaryEntity secondary;
// getter/setter omitted
}
@Entity
public class SecondaryEntity extends MySuperClass {
@Id
@OneToOne(optional=false)
private MainEntity main;
// getter/setter omitted
}
What I'm seing is that when I try to persist an instance of
SecondaryEntity, EclipseLink generates a SQL statement that repeats
the fields of the mapped superclass:
INSERT INTO SecondaryEntity ('field1', 'field2', 'version', 'foo', 'bar', 'field3', 'version', 'foo', 'bar', 'main_id') VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Of course, MySql complains: Column 'version' specified
twice
(I think it doesn't mention 'foo' and 'bar' because it stops at
'version', but they are repeated, too).
Am I doing something wrong? Is there a problem in EclipseLink
with the combination "shared primary key" and "mapped superclass"?
Thanks in advance.
Mauro
|