Removing and entity with and @JoinTable [message #643425] |
Mon, 06 December 2010 19:49 |
No real name Messages: 4 Registered: November 2010 |
Junior Member |
|
|
It appears that when we attempt to remove an entity the relationships within that entities @JoinTable are not removed.
The result is a SQL error that indicates that a "child record was found".
The confusing thing is that this code is fine in Hibernate. What is different in eclispselink?
With EclipseLink do children records have to explicitly be removed?
Did not see an annotation that would help...
Any input is appreciated.
Following is the code that attempts to remove the record and its children.
@Override
public void delete( RecipientPackageDeliveryPK id ) throws DataNotFoundException
{
RecipientPackageDelivery recipientPackageDelivery = entityManager.find( RecipientPackageDelivery.class, id );
entityManager.remove( recipientPackageDelivery );
entityManager.flush();
recipientPackageDelivery = null;
}
Following is the entity envolved and the @JoinTable...
@Entity
@Table( name = "CMM029" )
@Inheritance( strategy = InheritanceType.JOINED )
@DiscriminatorColumn( name = "DELIVERY_CHNL_ID", discriminatorType = DiscriminatorType.INTEGER )
public abstract class RecipientPackageDelivery implements Serializable
{
...
/** The documents. */
@JoinTable( name = "CMM031", joinColumns = { @JoinColumn( name = "PACKAGE_ID", referencedColumnName = "PACKAGE_ID" ),
@JoinColumn( name = "RECIPIENT_CDE", referencedColumnName = "RECIPIENT_CDE" ),
@JoinColumn( name = "DELIVERY_CHNL_ID", referencedColumnName = "DELIVERY_CHNL_ID" ) }, inverseJoinColumns = { @JoinColumn( name = "DOCUMENT_ID", referencedColumnName = "DOCUMENT_ID" ) } )
@ManyToMany
private List<Document> documents;
...
}
|
|
|
|
Powered by
FUDForum. Page generated in 0.03530 seconds