Mike Kienenberger wrote:
>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);
>
>
I wish it were that simple: I'm working on a (tapestry) web application
and my DataContext is stored in the session so there is, in reality,
only one (per client): I haven't initialized any other.
Btw, I initialize it like so:
public DataContext getContext() {
if (context == null) {
context = Configuration.getSharedConfiguration().getDomain(
"MyDomain").createDataContext();
}
return context;
}
I reference this context from all the pages in the application.
I don't think this is the problem as it works just fine in several other
applications I've written.
Any other ideas?
Tomislav
This archive was generated by hypermail 2.0.0 : Fri Aug 05 2005 - 07:53:03 EDT