Re: Register DO with DC Multiple Times?

From: Kevin Menard (kmenar..ervprise.com)
Date: Fri Jul 08 2005 - 08:06:59 EDT

  • Next message: jira-norepl..bjectstyle.org: "[OS-JIRA] Created: (CAY-343) ObjectStore.unregisterNewObjects() should not throw null pointer exception"

    Andrus Adamchik wrote:
    > This is fixed in CVS. I am curious though what exactly in your code
    > caused this problem to show up?

    I'm working on our new public web site and I was working on the account
    creation stuff. The way I have it structured currently is:

    Address ----- Shipping Info *-----
                                     |
                                     |---- Customer
                                     |
    Address ----- BillingInfo *-------
                         |
                         |
                    CreditCardCompany

    So, my code goes through, creates the addresses, associates them with
    either ShippingInfo or BillingInfo, which then have some other
    properties set, which then get associated with a given customer.

    CreditCardCompany is read-only and represents the current cc companies
    we have merchant accounts with. So, these are always retrieved from the
    DB and never modified. When I call setCreditCardCompany() on the
    non-registered BillingInfo instance, it's causing that object to get
    registered. Naively, later in my code I say "Well, billingInfo hasn't
    been registered yet, and Cayenne is going to make me cry if I try to
    call setAddress() on in it without first registering things", so I
    registered them and thus the problem.

    The real PITA part was the only way to retrieve BillingInfo instances
    (other than a direct query to the DB) is from Customer, but whenever I
    retrieved the list, it was size 1, but Cayenne was clearly trying to add
    more than 1.

    So, if it sounds like I did something bad, feel free to correct.
    Otherwise, thanks for such a quick fix. I would have logged it as a
    bug, but wanted to make sure I wasn't running into some "feature" first.

    -- 
    Kevin
    



    This archive was generated by hypermail 2.0.0 : Fri Jul 08 2005 - 08:07:02 EDT