• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Data integrity with ORMlite

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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.
reply
    Bookmark Topic Watch Topic
  • New Topic