I'm a little bit stuck with my db4o homework and I don't really know how to solve this.
The case is that I have a simple school student/credit/course database. Objects have following attributes:
Student:
Course:
Credit:
Now when deleting a course I should also delete the credit or credits that have reference to that course. I've read the db4o manual and tried to understand this whole cascadeOnDelete thing, but the first thing I'm not sure is that do I have to set the cascadeOnDelete to true for the course or for the credit object?
The next problem is that I should be able to find all the credits with the reference to that course. How to exactly do that in db4o?
The db4o manual has some examples, but with hard coded values so it's not very helpful. Is there a way to use SQL like queries in db4o to find the credits with the "correct" references?
Also do I have to store the course proto first, then find the credits and then delete the credits first and finally the course?
I'm quite confused here and don't know how to proceed so any help is appreciated. Thanks.
You can turn on cascading deletes on the db level or only for specific classes:
// 1: For the whole DB
container.Ext().Configure().CascadeOnDelete(true);
//2: For a specific type
container.Ext().Configure().ObjectClass(typeof(Circle)).CascadeOnDelete(true);
On codeproject.com is an article on deleting objects that provides further explanation.