Re: help on relationship

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

  • Next message: Jun Bondoy: "Re: help on relationship"

    I meant to add that the set* methods are for to-one relationships and
    the addTo* methods are for to-many relationships.

    /dev/mrg

    On 1/20/07, Michael Gentry <blacknex..mail.com> wrote:
    > 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:30:28 EST