Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Delete ManyToMany Relationship

Chris,

The problem is when trying to delete a Property.

predelete() seems to be an eclipselink internal method, from what I understand, that is supposed to cleanup references before an Object (in this case Property) is deleted.

I will try adding a constraint dependency of Coverage to property, i.e.  propretyRelationalDescriptor.addConstraintDependency(Coverage.class);, and see what happens

Thanks,

Tristan

On Wed, Dec 30, 2009 at 10:00 AM, Christopher Delahunt <christopher.delahunt@xxxxxxxxxx> wrote:
Hello Tristan,

I'm not sure what you mean when you say predelete() isn't called.  If Property has a M:M to Coverage, EclipseLink should clean up the reference table before it attempts to delete Property.  Is the problem that it is attempting to delete a Property or a Coverage when it hits the constraint violation?

If it is because the Coverage is being deleted first, unless Coverage has a read-only M:M (or some other mapping) to Property, EclipseLink has no way of knowing about the relation table when it goes to delete Coverage.  It does its best to figure out delete/insert orders up front, but sometimes needs to be told about relationships that require a certain order.  In these cases, you can either add a relationship (read-only) from Coverage to Property using the same relation table or you can add a constraint to the descriptor.  The constraint will tell it that the Properties need to be processed first, which will cause the relation table to be deleted correctly.  See http://www.eclipse.org/eclipselink/api/1.1.2/org/eclipse/persistence/descriptors/ClassDescriptor.html#addConstraintDependency(java.lang.Class)

Best Regards,
Chris

----- Original Message -----
From: tristan.paddock@xxxxxxxxx
To: eclipselink-users@xxxxxxxxxxx
Sent: Tuesday, December 29, 2009 12:03:32 PM GMT -05:00 US/Canada Eastern
Subject: [eclipselink-users] Delete ManyToMany Relationship


I am fairly new to ORMs and EclipseLink and am having trouble deleting
objects out of a DB because a rows in a cross-reference table are not being
deleted before an object is deleted and thus foreign key constraints are
violated.

Here is an overview of the part of the DB in question:

Property <-----> PropertyCoverageXref <-----> Coverage

PropertyCoverageXref contains the PKs of Property and Coverage.

The Property object contains a ValueHolderInterface to Coverage objects.
Coverage objects do not contain any reference to Property objects.

The DB mapping schema is built up using the EclipseLink Workbench.  The
coverageHolder attribute in Property is defined as a many-to-many
relationship to the Coverage descriptor.  The Table Reference Relation Table
is defined to be PropertyCoverageXref.  The Source and Target Reference are
set up to use the PKs of Property and Coverage respectively.


Here is the problem that I am having:  When I try to remove a Property
object via a UnitOfWork the 'predelete' never happens because the session is
a UnitOfWork when predelete() is called.

My guess is that I am missing some sort of configuration or something.  But
as I said, I have very limited experience with EclipseLink and I am at a
loss.  If there is more information that I should provide or something needs
clarifying please let me know.

Thanks for the help,

Tristan






--
View this message in context: http://old.nabble.com/Delete-ManyToMany-Relationship-tp26957070p26957070.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



--
Tristan Paddock

Tristan.Paddock@xxxxxxxxx
970.901.9400

Back to the top