Re: saveOrUpdate

From: Gili (cowwo..bs.darktech.org)
Date: Wed Sep 07 2005 - 13:18:56 EDT

  • Next message: Mike Kienenberger: "Re: saveOrUpdate"

            Right, the source-code checks for getDataContext()==null. If the
    dataContext is already registered and set to the current data-context it
    exits as a no-op. The problem I see with this is that I don't think
    getDataContext()==null is the right condition. What happens if I invoke
    DataContext.registerNewObject() on a DELETED object? I'd expect it to
    change its persistence state to MODIFIED. The current behavior will
    return as a no-op operation, which seems wrong to me. What do you think?

    Gili

    Mike Kienenberger wrote:
    > I'm pretty sure the thread you're referring to dealt with a rare case
    > where a registered object might be added a second time by the new
    > "auto-registering" behavior that occurs when setting relationships
    > between a registered object and a non-registered object.
    >
    > registerNewObject probably already insures that the object is
    > registerable. (You can always look at the source code and verify
    > it).
    >
    > If you want to be really paranoid, just insure that
    > object.getDataContext() == null before registering an object. The
    > above condition is the easiest way to determine if an object is
    > registered already.
    >
    > On 9/7/05, Gili <cowwo..bs.darktech.org> wrote:
    >
    >>Hi,
    >>
    >> This is related to
    >>http://www.objectstyle.org/cayenne/lists/cayenne-devel/2005/07/0006.html
    >>
    >> Hibernate has session.save(), update() and saveOrUpdate(). I'm looking
    >>for the equivilent of the latter in Cayenne. This is simply a
    >>convienience method that registers an object with the context if it
    >>isn't already registered. I would use it after foo =
    >>foo.getCanonicalState() because this method might return a registered
    >>object or it might return foo which is not yet registered.
    >>
    >> In the mailing list, when Andrus said this is "fixed" in CVS, did he
    >>mean that DataContext.registerNewObject() already behaves like I mentioned?
    >>
    >>Thanks,
    >>Gili
    >>--
    >>http://www.desktopbeautifier.com/
    >>
    >
    >

    -- 
    http://www.desktopbeautifier.com/
    



    This archive was generated by hypermail 2.0.0 : Wed Sep 07 2005 - 13:18:58 EDT