users@glassfish.java.net

Re: JPA cacade remove operation: Spec vs. TLE implementation

From: <glassfish_at_javadesktop.org>
Date: Fri, 10 Aug 2007 07:00:24 PDT

There is one more workaround:
  Add a constraint dependency on A to B - assuming A has the unidirectional OneToMany to B. This should cause TopLink to process As first, causes TopLink to clean up the relation table before deleting the A, and before attempting to delete Bs.

Customizers can be used to add constraint dependencies, which are useful when you have unmapped constraints in your objects. Try using a descriptor customizer on the A class, and then call descriptor.addConstraintDependencies(B.class);

This may not work in all cases - if the relation is self referencing or if there is another 1:1 from A to B that would force B to be deleted/processed first - but should still help until it can be fixed.

Best Regards,
Chris
[Message sent by forum member 'chris_delahunt' (chris_delahunt)]

http://forums.java.net/jive/thread.jspa?messageID=230468