Potential causes of duplicate key insertion by the eof
Potential causes of duplicate key insertion by the eof
- Subject: Potential causes of duplicate key insertion by the eof
- From: Des Oates <email@hidden>
- Date: Thu, 24 Mar 2005 23:26:32 +0000
I'm struggling a little trying to get to grips with inserting data
with my WO application. EOF appears to be trying to insert a duplicate
key into the database. I'm hoping someone on this fine list may have
come across this before...
I'm getting a SQL exception " Invalid argument value : Duplicate entry
'1121' for key 1. " The java stack trace shows the exception is thrown
when ec.saveChanges() is called, which isn't much help to me. When I
browse the table data '1121' sure enough is there. This happens if
even I start with a completely empty database.
Since EOF is responsible for generating primary keys at the DB end, I'm
assuming I'm either not managing the object graph correctly, or I've
not set up my EO Model correctly.
Does anyone have any tips on what other causes might be to blame for
this happening? I'm pretty sure I'm not inserting the same object
twice into the same EC in my code, but I'm not aware of any other
obvious causes of this.
I'm running a MySQL 4.1 on Windows on WO 5.2.2 with Eclipse/WOLips
Extra background info for the brave souls who have ventured this far :-)
I am adding a fairly complex object into my database using EOF, The
object is a containment hierarchy which contains subcomponents and
lists of subcomponents in a hierarchy similar to one you would find in
a large-ish XML file. Each child 'element' type corresponds to a
table. The code traverses through the hierarchy instantiating EOObjects
populating their data, and establishes a relationship with its
parents/siblings.
All objects in the hierarchy get created with
EOUtilities.createAndInsertInstance(). The parent object would call
this to create its children
The editing context gets passed into an 'init()' method in each child
so that the same ec is always used throughout the hierarchy.
The init() method gets called after the child is created is used to:
populate the attributes
establish the relationship with its parent by calling
addObjectToBothSidesOfRelationshipWithKey(parent "keyName")
construct its children, then call their init() method
And so on...
When the entire hierarchy has been constructed. ec.saveChanges() is
called. The duplicate key insertion error occurs in an object midway
in the hierarchy. Objects higher in the hierarchy are getting saved
prior to the error
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden