Nope thats the right way to go about. Add the child to the parent, and
tell child who its parent is. After that castor will take care of
everything else. Of course you could always make an addAttributeBean
function in the parent, and in there have it automatically set the
parent of the child. Same thing, but just hides it a bit better.

-Nick


On Wed, 5 Jan 2005 16:36:52 -0600, Jacob Tomaw <[EMAIL PROTECTED]> wrote:
> 
> Hello,
> 
> I have setup two objects with a one-to-many relationship.  Is there a
> way to have the linked field in the objects on the many side be set
> when the one object is created?
> 
>         JListBean listBean = new JListBean();
>         listBean.setName("Test List");
> 
>         JAttributeBean attrBean1 = new JAttributeBean();
>         attrBean1.setName("Test Attr");
> 
>         listBean.getAttributes().add(attrBean1);
>         attrBean1.setJList(listBean);
> 
> It seems I should only have to add the many object to the collection
> on the one.  The one object should automatically be set when it is
> created through Castor.
> 
> Am I going about this the wrong way?  Is this what everyone else has
> to do?  Is there a best practice for this?
> 
> Thanks,
> Jacob Tomaw
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-user
>



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to