Re: Duplicate record
Re: Duplicate record
- Subject: Re: Duplicate record
- From: Art Isbell <email@hidden>
- Date: Wed, 21 Jul 2004 12:39:16 -1000
On Jul 21, 2004, at 12:15 PM, A. Uchida wrote:
aNewProduct was my solution to insertObject. I wanted to insert
aProduct which contains
values showing on the DetailViewPage.
But if I do
ec.insertObject(aProduct);
nextPage.setAProduct(aProduct)
and edit the values and saveChanges(), then "data already in the
database" error.
Did you already insert aProduct on a previous component? Otherwise,
this looks like the correct approach. If you've already inserted
aProduct, don't insert it again.
So I created the aNewProduct to instert instead of aProduct.
At this line, aNewProduct.createdDate() returns Null, because aProduct
contains values.
How did you create aNewProduct? You don't show that code.
setANewProduct(aProduct);
This assigns the new empty Product, aProduct, to aNewProduct.
aProduct is not empty, as the values were passed from the previous
page.
How did you set the values of all of aProduct's attributes? It will
be empty unless you explicitly set all attribute values. You can't
merely assign a fully-initialized Product object to an empty Product
object to initialize the empty Product object. Such an assignment will
result in the empty Product object being garbage collected with two
Product variables referring to one fully-initialize Product object. I
suspect that this is what is causing the problem.
I supposed I have to do something like
nextPage.setAProduct(ec.insertedObjects())
but this gets compile error "impossible class to convert"
setAProduct()'s argument is a Product whereas ec.insertedObjects() is
an NSArray, so this is invalid Java.
Aloha,
Art
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.