Re: Join many to many problem
Re: Join many to many problem
- Subject: Re: Join many to many problem
- From: Art Isbell <email@hidden>
- Date: Thu, 27 Feb 2003 09:01:40 -1000
On Wednesday, February 26, 2003, at 10:04 PM, Buyung Pamungkas wrote:
The relationship
Progammer
- tasks (no destination, generated when I made
many-to-many relationship, I didn't make any changes)
- programmertasks (propagate primary key
Task
- programmers (no destination, generated when I made
many-to-many relationship, I didn't make any changes)
- programmertasks (propagate primary key
ProgrammerTask
- programmer (I didn't make any changes, shown in
server and client-side, locked)
- task (I didn't make any changes, shown in server and
client side, locked)
No problem when I execute SQL to database.
No problem when I built and ran application until I
tried to insert one record on ProgrammerTask.
I have insert "Buyung" on PROGRAMMER table and
"coding" on "TASK" table. When I inserted "Buyung" and
"coding" on PROGRAMMER_TASK, this is the error
messages :
"Save failed: Server exception: Adaptor
com.webobjects.jdbcadaptor.JDBCAdaptor@4e9dc5 failed
to provide new primary key for entity
'ProgrammerTask'!
The join entity, in your situation and many others, is really an
abstract entity that shouldn't be accessed at all. Because you have
the flattened relationships Programmer.tasks and Task.programmers, you
can't access ProgrammerTask from either Programmer or Task. So don't
try to insert an object into ProgrammerTask.
Instead, avoid thinking about the relational database and think about
what you'd do in the object world and let EOF manage the relational
database. Add the Task "coding" object to the Programmer "Buyung"
object's "tasks" relationship:
buyungProgrammer.addObjectToBothSidesOfRelationshipWithKey(codingTask,
"tasks")
Then save the editing context. Voila!
Art
http://homepage.mac.com/aisbell/
_______________________________________________
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.