-->
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: Joined-Subclass and AFTER DELETE trigger
PostPosted: Wed Jun 03, 2009 9:52 am 
Newbie

Joined: Wed Jun 03, 2009 8:24 am
Posts: 2
Hello all!

We are using the Joined-Subclass mapping strategy (table per subclass). The classes look like this:

----------------------------Transaction (Class)-----------------------

SaleTransaction (SubClass1)-----------------RefundTransaction(Subclass2)

We have an AFTER DELETE trigger on the SaleTransaction and the RefundTransaction tables to ensure that if a record on these tables is deleted, the corresponding record on the Transaction table gets deleted too.

The problem that we are facing is that when we are 'using' NHibernate to delete a record in the SaleTransaction or RefundTransaction tables, NHibernate's default behaviour is to automatically delete the record on the Transaction table as well, a record that is no longer there, because the Trigger has already deleted it, and this throws an error.

We would prefer to let the DB maintain referential integrity, so we wonder if there is a way to change this behaviour in Nhibernate.


Top
 Profile  
 
 Post subject: Re: Joined-Subclass and AFTER DELETE trigger
PostPosted: Wed Jun 24, 2009 8:50 am 
Newbie

Joined: Wed Jun 03, 2009 8:24 am
Posts: 2
We are still trying to find a way around this. Any ideas?

Thanx!


Top
 Profile  
 
 Post subject: Re: Joined-Subclass and AFTER DELETE trigger
PostPosted: Thu Jun 25, 2009 2:32 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
I don't think there's a way, because from hibernate's point of view these two rows belong together and can either exist both or none. The only way arround this, is by replacing the class hierarchy with associations. Something like that:

Transaction 1:n TransactionDetail

Then derive SaleTransaction and RefundTransaction from TransactionDetail.

_________________
--Wolfgang


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.