Re: weird behaviour with commit?

From: Mike Kienenberger (mkienen..laska.net)
Date: Thu Aug 04 2005 - 14:57:44 EDT

  • Next message: Hefest: "Re: weird behaviour with commit?"

    Hefest <Hefes..mail.com> wrote:
    > Hi everyone,
    >
    > I do something along the following lines:
    >
    > x= dc.createAndRegisterNewObject(MyClass.class);
    >
    > y.setSomeProperty("newValue");
    > y.setToMyClass(x);
    > dc.commitChanges();
    >
    > The problem is that "x" isn't linked with "o" after doing the commit so
    > at the moment I improvise doing
    >
    > x = dc.createAndRegisterNewObject(MyClass.class);
    > dc.commitChanges(); // this commit makes the y.setToMyClass(x) work
    > like intended
    >
    > y.setSomeProperty("newValue");
    > y.setToMyClass(x);
    > dc.commitChanges();

    Do you have both y and x in the same dc?
    Probably not. By default, y.setToMyClass(x) will try to convert x to y's
    dc if they are not the same.
    Since x is only a temporary object until it's committed, it probably won't
    survive the conversion.

    Try using:

    x = y.getDataContext().createAndRegisterNewObject(MyClass.class);



    This archive was generated by hypermail 2.0.0 : Thu Aug 04 2005 - 14:54:19 EDT