Important note
Don't forget to wrap the commitChanges with a try and catch statement,
and rollback if the insert/updates fail. Otherwise you might some
strange behaviour later on.
Fredrik
-----Original Message-----
From: Mike Kienenberger [mailto:mkienen..laska.net]
Sent: Wednesday, April 27, 2005 5:19 PM
To: cayenne-use..bjectstyle.org
Cc: cayenne-use..bjectstyle.org
Subject: Re: Saving a single object
=?ISO-8859-1?Q?Mika=EBl?= Cluseau <nwr..wrk.dyndns.org> wrote:
> I'm sorry to ask that but neither google nor the cayenne doc enlighted
> me on a stupid question... how do you save a single object? (yes, I
> must support this feature...)
The same way you save multiple items --
dataContextInstance.commitChanges();
A simplified free-form example off the top of my head so there's
probably
errors:
DataContext dc = DataContext.createNewDataContext();
MyObject mo = dc.createAndRegisterNewObject(MyObject.class);
mo.setBar("foo");
dc.commitChanges();
This archive was generated by hypermail 2.0.0 : Wed Apr 27 2005 - 20:21:24 EDT