Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » Removing and entity with and @JoinTable(the child records are not removed...)
Removing and entity with and @JoinTable [message #643425] Mon, 06 December 2010 14:49 Go to next message
Eclipse UserFriend
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;

...

}




Re: Removing and entity with and @JoinTable [message #643910 is a reply to message #643425] Wed, 08 December 2010 11:44 Go to previous message
Eclipse UserFriend
Hello,

Can you try calling refresh after the find and see if that helps? Does the Document have a back references to RecipientPackageDelivery? Which version/build are you using?

Best Regards,
Chris
Previous Topic:Property field not updated UNLESS 1st initialised
Next Topic:No OptimisticLocking when cache.shared.default=false?
Goto Forum:
  


Current Time: Fri Jul 04 16:13:28 EDT 2025

Powered by FUDForum. Page generated in 0.04395 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top