Does someone know if it is possible to establish a backreference from within a JPA @EmbeddedId
.
So for example there is an Entity of the Form
@Entity
public class Entity1 {
@Id
@GeneratedValue
private String identifier;
private Entity1 relationToEntity1;
//Left out the getters and setters for simplicity
}
And a second entity with a complex embedded Id. One part of this second entity is a reference to its parent entity. Like so:
@Entity
public class Entity2 {
@EmbeddedId private Entity2Identifier id;
//Left out the getters and setters for simplicity.
}
@Embedabble
public class Entity2Identifier {
private String firstPartOfIdentifier;
private Entity1 parent;
//Left out the getters and setters for simplicity.
}
When I try to save such a construct via JPA (Implementation is EclipseLink) to a database I get several exceptions of the form:
Exception [EclipseLink-93] (Eclipse Persistence Services - 1.1.0.r3639-SNAPSHOT):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The table [ENTITY1] is not present in this descriptor.
Descriptor: RelationalDescriptor(test.Entity2 --> [DatabaseTable(ENTITY2)])
Did someone encounter such a problem and has a solution?