Alternatively, it might be enough to catch NullPointerException around
this block and if context==null then throw
CayenneRuntimeException("To-one relationship object was unregistered
before being removed"). It would be clearer than throwing NPE.
Again, sorry for the false alarm :(
Gili
Gili wrote:
>
> I tracked this down. It's a bug in my code. It turns out my code
> invokes dataContext.unregisterObject(B) right before invoking
> A.setB(newB). So by this point, A is pointing to an unregistered B and
> it dies tried to remove the association.
>
> So clearly this is a mistake on my end (sorry), but I'm wondering
> whether it is possible to warn the user somehow that he removed
> registeration to an object which is still being referenced. I'm guessing
> not :( but it doesn't hurt asking...
>
> Thanks,
> Gili
>
> Andrus Adamchik wrote:
>
>>
>> On Sep 9, 2005, at 2:12 PM, Gili wrote:
>>
>>> willConnect() works fine for connecting A (which is registered) to B
>>> (which is not registered) but I think you need something like
>>> willDisconnect() for removing B (which is unregistered) from A
>>> (which is registered).
>>
>>
>>
>> If you are on 1.2, by the time C is added, B should be already
>> registered (due to willConnect(..)).
>>
>> And replacing one registered object with another in a relationship
>> works just fine. So if you don't find anything suspect in your code,
>> I'd say you should log your exception in jira.
>>
>> Andrus
>>
>
-- http://www.desktopbeautifier.com/
This archive was generated by hypermail 2.0.0 : Fri Sep 09 2005 - 14:38:21 EDT