Re: Weird Behaviour with Nullify rule

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Oct 20 2004 - 20:40:05 EDT

  • Next message: Andrus Adamchik: "Re: "Browse Data" tool for Cayenne Modeler"

    On Oct 20, 2004, at 11:09 AM, Jorge Sopena wrote:

    > Mike,
    >
    > Both objects have the same database information. But the method
    > hashCode() returns different result, so they are !equals() objects.
    > How can Cayenne know where two objects are the same?
    >
    > Jorge

    Jorge,

    Only now got a chance to scan through this thread... Could you post the
    code that shows the problem? It will be easier to make intelligent
    comments if I see the code ;-) A few points on the questions raised in
    the thread:

    1. Nullify rule: it affects the target behavior when the source is
    deleted. So if "Company.listPaths" has a Nullify rule, it will nullify
    path -> company pointer if the company is deleted, not the other way
    around
    (http://objectstyle.org/cayenne/modelerguide/modeling-object-layer/
    delete-rules.html)

    2. Cayenne ensures that there is at most one instance of each
    DataObject in any given DataContext (so overriding "equals" is evil,
    lets get to the core of the problem instead). So if it appears that
    there are two objects that are the same, I guess one of them is
    "transient", i.e. has DataContext set to null and is therefore != to
    the one that has a non-null DataContext.

    So my advise would have been to set "path -> company" relationship rule
    to nullify, still I am probably missing something, as you say you
    delete Path3, and then you are able to fetch it again? I am confused...

    Andrus



    This archive was generated by hypermail 2.0.0 : Wed Oct 20 2004 - 20:40:08 EDT