When mapping an Embeddable to a SecondaryTable we get the following exception:
this is the embeddable causing the problem:
@Embeddable
public class EmbeddableWithCodes {
@Embedded
private SimpleEmbeddable code1;
@Embedded
private SimpleEmbeddable code2;
private String name;
...
and the mapping in the containing class:
@Embedded
@AttributeOverrides({ @AttributeOverride(name = "code1.code", column = @Column(table = SECONDARY, name = "CODE1")),
@AttributeOverride(name = "code2.code", column = @Column(table = SECONDARY, name = "CODE2")),
@AttributeOverride(name = "name", column = @Column(table = SECONDARY, name = "NAME")) })
private EmbeddableWithCodes embeddableWithCodes;
after some debugging we found, that renaming the property "name" to "a_name" resolved this issue. The naming affects the sequence of processing of the properties. When the first property is a SimpleType the Table is switched to the SecondaryTable and subsequent properties pass without problem.
the working embeddable:
@Embeddable
public class EmbeddableWithCodes {
@Embedded
private SimpleEmbeddable code1;
@Embedded
private SimpleEmbeddable code2;
private String a_name;
...
and the mapping in the containing class:
@Embedded
@AttributeOverrides({ @AttributeOverride(name = "code1.code", column = @Column(table = SECONDARY, name = "CODE1")),
@AttributeOverride(name = "code2.code", column = @Column(table = SECONDARY, name = "CODE2")),
@AttributeOverride(name = "a_name", column = @Column(table = SECONDARY, name = "NAME")) })
private EmbeddableWithCodes embeddableWithCodes;
I attached two projects, one to show the problem and the other to demonstrate the workaround.
|