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/
>
This archive was generated by hypermail 2.0.0 : Wed Sep 07 2005 - 10:47:08 EDT