[baseten-users] one-to-many relationship strange behavior

Tuukka Norri tuukka.norri at karppinen.fi
Thu Sep 10 23:17:26 EEST 2009


Hi again!

I made a simple example on using a one-to-many relationship. It's  
available in the repository at http://basetenframework.org/svn/trunk/Examples/OneToManyRelationship/
I also fixed a bug which might have caused the wrong relationship to  
be used when creating related objects.

> 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).
OK, this is a bit strange, since many-to-many relationships should  
require some additional work.

> But when I delete a Project, the respective ProjectItems are not  
> deleted as well, they reside in the Database without relationship.
Unfortunately, making many-to-many relationships cascade on delete  
isn't especially easy either, because they are implemented with a link  
table. To me, making both sides cascade on delete wouldn't even make  
much sense, since removing one object could very quickly cascade to  
all objects. If you have a use case for this functionality, though,  
we'll definitely consider adding it.
-- 
Best regards,
Tuukka Norri
MK&C




More information about the baseten-users mailing list