-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Deleting Associated Objects
PostPosted: Wed Dec 17, 2003 1:27 pm 
Beginner
Beginner

Joined: Mon Sep 29, 2003 3:10 pm
Posts: 36
While I've been using Hibernate for several months now, I still occasionally stumble upon things that I've fundamentally misunderstood with regards to this tool, so I wanted to confirm that I'm correctly handling entity deletion in my system.

I have an entity, QuestionGroup that is associated with a number of other entities in my system.
- It is a child (in a many-to-many relationship) of Assessment
- It has a many-to-one relationship with QuestionGroupAttempt
- It is a parent of multiple Question entities
- etc.

I believe that I have a fairly good handle on how to properly remove a QuestionGroup and it's child Question objects. This is covered quite thoroughly in "Section 8: Parent Child Relationships" in the Hibernate Documentation.

What I'm curious about is how deletions should be handled with regards tot he other relationships that QuestionGroup is a part of. Perhaps I'm being naive, but it seems that Hibernate is aware of the relationships that exist between QuestionGroup and Assessment, for instance, and that if I were to remove a QuestionGroup which belonged to an Assessment, Hibernate would know to remove the relationship between these two entities. The same would seem true for the many-to-one relationship with QuestionGroupAttempt.

However, what I'm finding is that in order to avoid a foreign key violation when deleting a [i]QuestionGroup[i], I need to remove these relationships manually. That's ok. It's a little extra work that I wasn't expecting, but I really don't have a problem with that. However, I wanted to make sure, by asking here, that I wasn't missing something obvious to make this all a little more transparent.

Thanks!
-Matt


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2003 2:47 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Your many-to-one should not be an issue since QuestionGroup is responsible of the association management.

For others, Hibernate use the Java semantic (minus the inverse=true, which can be arguable). You must remove links as you would do in a plain Java model.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2003 2:55 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
http://forum.hibernate.org/viewtopic.php?t=926445

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.