Cómo establecer una referencia inversa de un @EmbeddedId en JPA
¿Alguien sabe si es posible establecer una referencia inversa desde un JPA?@EmbeddedId
.
Entonces, por ejemplo, hay una Entidad del Formulario
@Entity
public class Entity1 {
@Id
@GeneratedValue
private String identifier;
private Entity1 relationToEntity1;
//Left out the getters and setters for simplicity
}
Y una segunda entidad con un Id. Incrustado complejo. Una parte de esta segunda entidad es una referencia a su entidad matriz. Al igual que:
@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.
}
Cuando intento guardar una construcción de este tipo a través de JPA (la implementación es EclipseLink) en una base de datos, obtengo varias excepciones del formulario:
<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>
¿Alguien encontró tal problema y tiene una solución?