Re: Owns destination and other relationship constraints ...
Ashley Aitken <[email protected]> Fri, 16 Apr 2004 22:34:36 +0800
| Newsgroups | gmane.comp.web.webobjects.eof |
|---|---|
| Message-ID | <[email protected]> |
Hi Alexander, Thanks for your post. On 14/04/2004, at 4:32 PM, Alexander Spohr wrote: > Am 14.04.2004 um 09:35 schrieb Ashley Aitken: >> 1. How does one move an object from one aggregate to another? Does >> it just work, to remove it from one aggregate and add it to another, >> for example, in code, or will this cause a problem. > > no problems here. the deletion will occur in saveChanges, not earlier. > if you hang it into a new relationship it will not be deleted. Great, good to know thanks. I was hoping for that. >> 2. If you have a relationship set as "owns destination" *must* the >> reverse relationship be mandatory and cascade or deny delete? >> Optional and nullify or no-action sound problematic. I'm sorry, my writing was confused here (I have been working long hours lately). I was suggesting that for a relationship set as "owns destination": 1. Reverse relationship should be mandatory. Since these objects only live as owned objects ... (and as you say, as long as this is true when saveChanges is called). Optional would mean they could live outside of a relationship. 2. The "owns destination" relationship must also have delete rule cascade or deny. If you delete the owner then you should delete the owned (cascade), or you must delete the owned before you delete the owner (deny). I hope that is more clear. The only problem is that it is wrong. I recently got thhis error from EOF that said an "owns destination" relationship can not have deny delete rule: > java.lang.IllegalStateException: The relationship "contacts" is > marked "Owns Destination" on the entity "Client". It cannot have a > delete rule of Deny or Nullify. > > Reason: > The relationship "contacts" is marked "Owns Destination" on the > entity "Client". It cannot have a delete rule of Deny or Nullify. So why not cascade? > > cascade could cause a problem :) think about it... If you are referring to the reverse relationship then I understand and apologise for my poor wording. But why would this be for the "owns destination" relationship? > mandatory means that eof has to create a target object if you don't > deliver one. not necessary here. Again, for the reverse relationship, I see how this is not necessary, but it does describe the situation correctly? > deny should not work either. that will prevent eof from deleting the > "owned" object. For the reverse relationship, yes. > so just do nothing of it at the inverse relationship. That's the easy solution ;-) You mean forget about the reverse relationship? That's the easy solution ;-) Cheers, Ashley. -- Ashley Aitken Perth, Western Australia mrhatken at mac dot com