Am a newbie to Java Persistence API. In our database, we have a one-to-many relationship between 2 tables, say t1 & t2 i.e. one record of t1 can be associated with multiple records in table t2. Is it possible to delete a row in t2 without doing anything to the associated row in t1? Is this allowed in JPA? I heard that an error saying "parent is null' is thrown in such a case?
it depends, mostly on what your tables actually look like.
Assuming you have a column on t2 linking the row to the 'parent' row in t1, you should be able to delete the t2 row. You'll want to consider any other ongoing activities / transactions on the database, of course.
When working with object persistence technologies, you'll typically want to modify your persistent objects through the application (and, therefore, your persistence technology) rather than directly through the database. In this case, you'd probably want to talk about deleting or removing an object rather than deleting a row in the database.
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
ScroogeXHTML 8.7 - RTF to HTML5 and XHTML converter