instantiate
populate
aCD.setLocation(aLocation);
aLocation.save();
aCD.save();
john mcnally
Saimon Moore wrote:
>
> I've been mucking around with turbine and currently I'm trying write a
> doInsert() method to take the form data and save it the DB.
>
> In the form, I have two tables
> <table name="CD" /> and <table name="Location" />
> CD contains a foreign key to Location.
>
> I've had a look at the documentation for inserts with peers and I reckon that
> I would have to add a join to the criteria and then do the insert.
> But I'm not comfortable with peers yet and I'm a bit confused as to how to go
> about this. I can understand doing selects with joins but with inserts I'm
> not quite sure yet...
>
> Here is my attempt..
>
> <code>
>
> //Create an object mapped to the DB table for each of the tables
> //used in the CdAdmin form...i.e. CD & LOCATION
>
> CD aCD = new CD();
> Location aLocation = new Location();
>
> //Use the RunData object (Has all the data from the request) tof ill-in
> //all the fields for each of the objects
> data.getParameters().setProperties(aCD);
> data.getParameters().setProperties(aLocation);
>
> Criteria criteria = new Criteria();
>
> criteria.add(CDPeer, aCD);
> criteria.add(LocationPeer, aLocation);
>
> criteria.addJoin(CDPeer.LOCATION_ID, LocationPeer.LOCATION_ID);
>
> Object o = CDPeer.doInsert(criteria); //Should I use CDPeer with this
> //or LocationPeer or one for each
>
> </code>
>
> I would really appreciate a hint or two on how to get kicking with this...
>
> Thanks,
>
> Saimon Moore
>
> _________________________________________________________
>
> Do You Yahoo!?
>
> Get your free @yahoo.com address at http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]