Jorge Sopena <jsopen..idsa.es> wrote:
> Eric,
> I just create a DatContext in my doGet() method of my servlet, in the
> following way:
> ctxt = BasicServletConfiguration.getDefaultContext(session)
>
> Each time I receive a request, a new DataContext would be created,
> wouldn't it?
>
> What my application has to do is to register these requests with the
> customer who did it.
> So I create a new Request object in that way:
> req =(Request)ctxt.createAndRegisterNewObject("Request");
>
> And then I set the customer to the request:
> r.setCustomer(Customer.search(clientId));
>
> And it's in that moment when this error happens.
>
> But the weird thing is that happens only when I do several request
> quickly, if they are separated in time everything goes right.
What you haven't described is what DataContext the result from
Customer.search(clientId) uses.
If it's not the same as ctxt, you will get an error.
If you want to understand what's happening, try outputing the datacontext
for both "r.dataContext()" and "Customer.search(clientId).dataContext()."
You will probably notice a pattern that will explain the observed behavior.
In any case, as I stated yesterday, if you use
r.setCustomer(r.dataContext().localObjects(Arrays.asList(new Object[] {
Customer.search(clientId) } )));
the problem should go away.
If it did not, that would indicate a bug in the cayenne framework.
-Mike
This archive was generated by hypermail 2.0.0 : Tue Mar 16 2004 - 09:21:42 EST