Insert statements generated with the same attribute repeated multiple times [message #1523033] |
Mon, 22 December 2014 17:49 |
Mauro Molinari Messages: 285 Registered: July 2009 |
Senior Member |
|
|
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 generated a SQL statement that repeats the fields of the mapped superclass:
INSERT INTO SecondaryEntity ('field1', 'field2', 'version', 'foo', 'bar', 'field3', 'version', 'foo', 'bar') 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"?
I would really appreciate any help, I'm quite in an urgent situation and I don't know how to fix this without heavily changing my entities (by removing the shared primary keys... I have quite a few).
Thanks in advance,
Mauro
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03909 seconds