31 Jul 2012 23:00
Deleting n:m relationships
Tobias Wolff <wolff <at> evaluegroup.com>
2012-07-31 21:00:03 GMT
2012-07-31 21:00:03 GMT
Hi,
I am currently trying to do the following in Cayenne 3.0.2:
* fetch an object A
* delete some related objects which are related to A in an n:m relation
* add new objects to A (same n:m relation)
I have undergone a couple of java.util.ConcurrentModificationException
and org.apache.cayenne.validation.ValidationException exception without
being able to fix them. Here is some code, but a general hint on how to
achieve that (especially when to do commits) would be much appreciated.
* Class Forecast
* Class LineItem
* Class ForecastCondendingLineItem (n:m relation between Forecast and
LineItem)
I have an object F of class Forecast which I have pulled from the
database. Now I try to delete the n:m relations like this:
for(ForecastContendingLineItem temp :
F.getForecastContendingLineItemArray()) {
F.removeFromForecastContendingLineItemArray(temp);
context.deleteObject(temp);
}
This results in the ConcurrentModificationException. I also tried this:
context.deleteObjects(F.getForecastContendingLineItemArray());
(Continue reading)
RSS Feed