Re: help on relationship

From: Michael Gentry (blacknex..mail.com)
Date: Sat Jan 20 2007 - 10:25:56 EST

  • Next message: Michael Gentry: "Re: help on relationship"

    When you model the relationships in Cayenne Modeler and then generate
    the Java classes, it'll create set* methods and addTo* methods for
    your relationships.

    So in your case, something similar to this should work:

    Category category = [code to get your Category object];
    Product product = dataContext.createAndRegisterNewObject(Product.class);
    product.setCategory(category);
    ...

    /dev/mrg

    On 1/20/07, Jun Bondoy <dvbondo..mail.com> wrote:
    > Hi list,
    >
    > can somebody help me please. i have a products object with to-one
    > relationship with my categories object. what i want to do is create a new
    > products and use an existing categories object. below are the steps i did...
    >
    > 1. lookup for my existing categories via query
    > 2. create a new product object
    >
    > how can i set the product object on the categories object before i commit?
    >
    > thanks in advance..
    >
    > Best Regards
    > -jun
    >
    >



    This archive was generated by hypermail 2.0.0 : Sat Jan 20 2007 - 10:26:22 EST