Hi Andrus,
thanks for that. I think I'd tried it before but ran into validation
problems (I had a setToItemType() method and the db field is required).
Since then I've looked through and overridden the validateForSave method
(can't remember why). I should be able to modify this method to allow for
direct and indirect access.
Cheers,
Dave
> -----Original Message-----
> From: Andrus Adamchik [mailto:andru..bjectstyle.org]
> Sent: 10 April 2006 12:50
> To: cayenne-use..ncubator.apache.org
> Subject: Re: Object Creation and Settings Ids
>
>
> Technically this can be done by mapping a foreign key column as an
> ObjAttribute. Still it would go against the spirit of Cayenne. I
> suggest to use a real ItemType object. DataObjectUtils.objectForPk
> (..) should be a pretty efficient way to get a hold of ItemType
> instance, as after the object is fetched for the first time, it will
> be served from shared cache on subsequent calls.
>
> Andrus
>
>
>
> On Apr 10, 2006, at 2:02 PM, Dave Merrin wrote:
> > Hi,
> >
> > Given a new object I'd like to be able to set on of the properties
> > (a 'to'
> > property) without having the other object(only the ID). e.g.
> >
> > Item is the object I'm creating. It has a property called ItemType
> > which is
> > another object. I have the ItemType ID but not the actual object.
> > I'd like
> > to have a method called Item.setItemTypeID(Long itemTypeId).
> >
> > Is this possible?
> >
> > Cheers,
> >
> > Dave
>
This archive was generated by hypermail 2.0.0 : Mon Apr 10 2006 - 10:59:36 EDT