Como definir uma referência anterior de um @EmbeddedId na JPA
Alguém sabe se é possível estabelecer uma referência retroativa dentro de uma JPA@EmbeddedId
.
Então, por exemplo, há uma Entidade do Formulário
@Entity
public class Entity1 {
@Id
@GeneratedValue
private String identifier;
private Entity1 relationToEntity1;
//Left out the getters and setters for simplicity
}
E uma segunda entidade com um ID incorporado complexo. Uma parte desta segunda entidade é uma referência à sua entidade mãe. Igual a:
@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.
}
Quando tento salvar essa construção via JPA (Implementation is EclipseLink) em um banco de dados, recebo várias exceções do formulário:
<pre><code>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)])
</code></pre>
Alguém encontrou esse problema e tem uma solução?