posted 11 years ago
I have a Question class that contains a list of Answer objects. In my POJOs I represent this in my Question class as
and in my Answer class this relationship is declared as
I had expected that ORMlite would throw an exception if I tried to persist an Answer which referenced a Question that had not yet been persisted to the database. However, this does not appear to happen. I can persist Answer objects as I please without saving the referenced Question objects. I verified the Answers are being saved with no questions being saved by looking in my database using SQLliteBrowser. This breaks my data integrity as when I restart my program the db now contains Answers that reference non existing questions. Is there any way to enforce this? With my experience in Hibernate it will not allow you to save the Child object without first saving the referenced "Parent" object.