[baseten-users] one-to-many relationship strange behavior
Michael Ruepp
michael at ruepp.at
Wed Sep 9 01:42:00 EEST 2009
Hi there,
I have some Problems creating a simple two entities one-to-many
relationship just in IB like I saw it in a Tutorial for CoreData.
It don´t work as expected:
Entity one is "Projects" with a to many relationship to "ProjectItems".
- to-many Relationship of Projects to ProjectItems is called
"ProjectItems"
- to-one Rel. of ProjectItems to Projects is called "Projects"
Both Entities just have the Properties "name".
I have two NSTableViews, a Database Context and two
BXSynchronisedArrayControllers, one named "Projects", the other
"ProjectItems-Projects".
Both are connected to the DBContext. Both have the names of their
TableNames properly set up.
The "Project" Controller has "Fetch automatically clicked on, the
"ProjectItems-Projects" Controller not.
I bound the ContentSet of the ProjectItem-Projects Controller to the
Project Controller with selection and the KeyPath name of the
relationship "ProjectItem"
I bound the "name" column of the Projects TableView to the Projects
Controller, arrangedObjects with Keypath "name".
I bound the "name" column of the ProjectItems TableView to the
ProjectItems-Projects Controller, arrangedObjects with Keypath "name".
I have four buttons, plus and minus for Projects and plus and minus
for ProjectItems. I added the add/remove Connection to the respective
Controllers.
So Database Connection is working, I am able to create Projects, but
when I try to create ProjectItems, nothing happens.
Funny enough, whan I change the Data Model to a many-to-many
relationship (Both sides cascade on delete) , I am able to create
Projects and ProjectsItems and Selection behavior is as excpected (eg.
Select a Project shows the respective ProjectItems created with the
Project selected).
But when I delete a Project, the respective ProjectItems are not
deleted as well, they reside in the Database without relationship.
Is this a bug or am I expecting something wrong? I created a coredata
Project that way and it works perfectly. I tried also to use Content
Array because in the documentation is something about "returns a
collection", but I really am confused about the way I should create a
one to many relationship.
Hopefully, somebody reads this, seems that the Baseten mailinglist is
somehow an empty one-way datahighway into nothingness :-) It is
Thanks,
Mike
More information about the baseten-users
mailing list