-->
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.  [ 2 posts ] 
Author Message
 Post subject: Delegate cascade delete on foreign key to underlying RDBMS?
PostPosted: Thu May 08, 2008 8:07 am 
Newbie

Joined: Mon Aug 07, 2006 2:35 pm
Posts: 7
Location: Poland
Hi,
is it possible to force schema exporter to generate on-delete=cascade in generated foreign keys?
In my case database is sometimes edited (records are removed) manually and without automatic cascade deletions it almost 100% probability of getting inconsistent data.

Thanks in advance,
Andriy Korud


Top
 Profile  
 
 Post subject: questions
PostPosted: Sun May 11, 2008 8:56 am 
Senior
Senior

Joined: Sun Jun 11, 2006 10:41 am
Posts: 164
Are you using hibernate core or annotations?
I've been able to achieve this with annotations, using the @OnDelete annotation. I'm sure there's an equivalent in hbm mapping files.
However, I did notice the following:
In one-to-many, the @OnDelete was declared on the non-owning side of the relationship (i.e. the parent). For example, in a company-employee relationship, I declared it in company.
In one-to-one, the @OnDelete was declared on the owning side (i.e. the "child" or "inner" entity). For example, in a body-heart relationship, I delcared it in heart.
I was unable to get it declared on foreign keys that associate subclasses and their superclasses in the joined sub class inheritence strategy, so I eventually stopped using hibernate's scheme generation. I only used it to initally get a reasonable schema, and then I continued to maintain it in external scripts (note that even hibernate recommended that auto-generation of schema should not be used in production...)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.