Bug in child contexts?

From: Kevin Menard (kmenar..ervprise.com)
Date: Tue Mar 04 2008 - 12:24:39 EST

  • Next message: Michael Gentry: "Re: Bug in child contexts?"

    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



    This archive was generated by hypermail 2.0.0 : Tue Mar 04 2008 - 12:26:31 EST