aspose file tools
The moose likes Object Relational Mapping and the fly likes JPA Question : Deletion w.r.t One-to-many relation    Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "JPA Question : Deletion w.r.t One-to-many relation    " Watch "JPA Question : Deletion w.r.t One-to-many relation    " New topic
Author

JPA Question : Deletion w.r.t One-to-many relation

G Priya
Greenhorn

Joined: Apr 30, 2007
Posts: 11
Hi,

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?

Thanks.
Oliver Kamps
Greenhorn

Joined: May 15, 2007
Posts: 18
Hi,

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.

Cheers,
Oliver
 
 
subject: JPA Question : Deletion w.r.t One-to-many relation
 
Threads others viewed
join()
Cannot understand MySqlQuery Working.
make array of hidden fields
OK, so how do I get the source from a document?
Temporary objects
IntelliJ Java IDE