Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
-
Click 0.18 (but I believe it is the same in current CVS version)
Description
Calling CayenneForm.getDataObject() more than once for the NEW object results in duplicate insert. I have a case when I need to manipulate a DataObject before saving it, so the action method code looks like this:
// 'getDataObject() - call #1
JobPost post = (JobPost) form.getDataObject();
// do something to POST
...
// 'getDataObject() - call #2
form.saveChanges()
here two records are inserted instead of one.
So maybe we should store DataObject in a transient field of the form for the duration of request, so that consecutive calls to getDataObject do not instantiate it again?