Hi,
I am new to both JDO and ObjectDB, and am struggeling to figure out how to define foreign key relationships.
For instance, I have create two classes:
@Entity public class Person implements Serializable{ @PrimaryKey private String name; private int age; ...} @Entity public class Company implements Serializable{ @PrimaryKey private String name; private Person employee; ...}
When I save a Company object that points to a Person object (using pm.makePersistent()) I get one entry for the Company and one entry for the Person in the db - as expected.
When I try to delete my Person object (pm.deletePersistent()), I am allowed to do so. Since the person is referred to from the company, I would have preferred to get an exception instead. How can I control this behaviour?
Also, how can I control cascading updates and deletes in JDO? There seems to exist a @ForeignKey annotation in JDO, but it doesn't seem to affect the behaviour of my classes. Also, this annotation does not seem to be present in the online ObjectDB JDO annotation list, so this may not be supported by ObjectDB?
Any help appreciated!