-->
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.  [ 1 post ] 
Author Message
 Post subject: Delete problems
PostPosted: Mon Jun 25, 2007 12:10 pm 
Newbie

Joined: Sun Mar 18, 2007 12:15 pm
Posts: 19
Hi.
I have a problem deleting objects. The setup is like,,, a Department can have many Professors.
I have a table for the department, and a table for persons. Linking them together I have a table called Department Professor.
Instead of having a many to many relationship, I am using many-to-one and one-to-many. The reason is that the Department Professor table must contain arbitrary data.

My problem is... when deleting a Person,,, I get an error saying that I am breaking a reference constraint. There is a reference to the person in the Department Professor table.
To me it seem like NHibernate is deleting objects in the wrong order. It should have been deleting the referenced object in the Department Professor table before deleting the person.
Of course could I manually delete the object in the Department Professor table,,,,,,, but I prefer to let the NHibernate do the job.

What am I doing wrong?
//regards Lasse


Departments:
Code:
...
...
<bag name="Professor"  inverse="false" table="Professor" cascade="all-delete-orphan" lazy="false" >
   <key column="ProfId"></key>
   <one-to-many class="ClassProfessor,asm"/>
</bag>
...
...



Department Professor:
Code:
....
....
<many-to-one name="Item" class="Person, asm" cascade="save-update" lazy="false"></many-to-one>
....
....



Person:
Code:
....
....
<bag name="Professor" inverse="false" table="Professor" cascade="all-delete-orphan" lazy="false">
   <key column="Item"></key>
   <one-to-many class="DepartmentProfessor,lgTronic.Spada.Business.Entities"></one-to-many>
</bag>
....
....


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

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.