-->
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: Changes to be made if I remove the foreign key constraints
PostPosted: Mon Mar 27, 2006 7:15 pm 
Newbie

Joined: Wed Oct 12, 2005 11:16 am
Posts: 13
Hi

We use hibernate2, java, spring, tomcat and oracle10g.

I want to remove the foreign key constraints on one table so that the table no more has many-to-one relation with its parent table.

When I do this, I update the hibernate mappings accordingly by removing the one-to-many / many-to-one mappings between the two tables.

Will this be sufficient or should I remove the relation between the two corresponding Java objects (of the two tables) also? Basically I am trying to enforce the relation between the two objects in the hibernate layer even though there is no relation between their tables? Is it possible?

Thanks in advance

Sri


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 28, 2006 1:15 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
If you want to keep the relationship but drop the foreign key (for performance reasons), then you should probably keep the relationships in the mappings. Hibernate doesn't care about foreign keys, it will carry on like it always has if you drop them. If you drop the relationship in the mapping file, then all the power of hibernate goes with it.

Note that you're opening yourself to a certain level of brittelness if you drop the DB relationships. Theoretically, someone could add now delete a row manually, leaving orphaned objects that your app will never be able to find (if it only ever finds child objects by navigating from their parents).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 28, 2006 11:46 am 
Newbie

Joined: Wed Oct 12, 2005 11:16 am
Posts: 13
Tenwit

Thank you for your prompt response.

Sri


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.