• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Duplicate record
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Duplicate record (From: "A. Uchida" <email@hidden>)
 >Re: Duplicate record (From: Hunter Hillegas <email@hidden>)
 >Re: Duplicate record (From: "A. Uchida" <email@hidden>)
 >Re: Duplicate record (From: Hunter Hillegas <email@hidden>)
 >Re: Duplicate record (From: "A. Uchida" <email@hidden>)
 >Re: Duplicate record (From: Hunter Hillegas <email@hidden>)
 >Re: Duplicate record (From: "A. Uchida" <email@hidden>)
 >Re: Duplicate record (From: Art Isbell <email@hidden>)

  • Prev by Date: Re: Are Apple's Java docs any good?
  • Next by Date: Re: Are Apple's Java docs any good?
  • Previous by thread: Re: Duplicate record
  • Next by thread: Re: Duplicate record
  • Index(es):
    • Date
    • Thread