aspose file tools*
The moose likes Android and the fly likes Data integrity with ORMlite Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Data integrity with ORMlite" Watch "Data integrity with ORMlite" New topic
Author

Data integrity with ORMlite

james frain
Ranch Hand

Joined: Apr 06, 2011
Posts: 36


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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Data integrity with ORMlite