cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Gentry" <blackn...@gmail.com>
Subject Re: Bug in child contexts?
Date Tue, 04 Mar 2008 17:35:09 GMT
What you describe is not functioning the way I would've expected (or
at least hoped).  I did some testing on nested ECs before and ran into
a few glitches, but never completely isolated the reason why.

/dev/mrg

On Tue, Mar 4, 2008 at 12:24 PM, Kevin Menard <kmenard@servprise.com> wrote:
> Hi,
>
>  This seems like such a basic question that I probably shouldn¹t have to ask,
>  but I want to verify intended behavior versus a bug.  Since Cayenne doesn¹t
>  allow one to associate two data objects from distinct contexts, we use local
>  object.
>
>  So, I have something similar to the following:
>
>  ObjectContext customerContext;
>  Customer customer = customerContext.newObject(Customer.class);
>
>  ObjectContext childContext = customerContext.createChildDataContext();
>  BillingInfo bi = childContext.newObject(BillingInfo.class);
>
>  The bi instance is created in its own context so that if the user doesn¹t
>  commit the page, I can toss the data without affecting the customer context.
>  If the user does save the form, then I want to do something like
>  bi.setCustomer(customer);  However, they¹re in different contexts, so that
>  doesn¹t work.  Additionally, bi has relationships to other entities in
>  childContext.  So, in this case, I use localObject to pull customer into
>  childContext, set the relationship, commit, and go on my merry way.
>
>  The problem is that calling customer.getBillingInfo() now returns billing
>  info associated with the child context.  I thought that they would be HOLLOW
>  objects resolved with the customer¹s context, but it appears due to caching
>  I now have a situation that Cayenne normally won¹t allow: two related
>  objects in different contexts.
>
>  Is this the way it¹s supposed to work for child contexts or have I run into
>  a bug?  Either way, I¹ll need to fix it.  I just need to know which codebase
>  to work with.
>
>  Thanks,
>  Kevin
>

Mime
View raw message