cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Gentry" <blackn...@gmail.com>
Subject Re: help on relationship
Date Sat, 20 Jan 2007 15:25:56 GMT
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 <dvbondoy@gmail.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
>
>

Mime
View raw message