syg6 wrote:
1. Load ObjectA from database (to get existing ObjectB Collection).
2. Use ObjectBManager to get() each ObjectB

Huh? Shouldn't ObjectA contain a collection of ObjectBs? Why do you need to to some other source for these objects? When I mentioned manipulating the collection contained in ObjectA carefully I was explicitly talking about the collection object, not the ObjectBs contained within it.

3. Use ObjectBManager to remove() each ObjectB
4. Call ObjectAManager.save()

If ObjectA contains a collection that references ObjectBs that have been deleted, then your ObjectA is in an invalid state. You shouldn't remove an ObjectB from the DB without first removing it from every collection it is in.

objectA.setObjectBs(null) I get a 'A collection with
cascade="all-delete-orphan" was no longer referenced by the owning entity
instance' error.

Right--that's specifically complaining about the collection, which is managed by Hibernate so that it can figure out which entries are no longer present so it can detect orphans. Try replacing "objectA.setObjectBs(null)" with

if (objectA.getObjectBs() != null) {
  List<ObjectB> asListOfBs = objectA.getObjectBs();
  asListOfBs.clear();
  objectA.setObjectBs(asListOfBs);
}

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to