-->
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: Ways to Handle Foreign Key Mapping
PostPosted: Wed Aug 18, 2004 8:00 am 
Newbie

Joined: Tue Jun 22, 2004 3:45 am
Posts: 3
Hibernate version: 2.1

Name and version of the database you are using: Oracle / Postgresql

Hi I am Newbie to Hibernate . I have few queries on delete operation.

I will take dept and employee as example. Say this dept is used in many places . Suppose I want delete the dept I want to do a check whether the department is having any employee or any childs . If there , then I have to throw any exception for this . In short , I want to detect the assocations at runtime and if any child is found I have to throw a exception . I am using a <property> to represent the dept in emp.hbm.xml . (This is just for example - Rather in this context <many-to-one> makes sense). I want to know what type of mappings will help in this manner . Also the mapping should be lazy loading as this dept can be used in "N" places .


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 12:54 am 
Newbie

Joined: Tue Jun 22, 2004 3:45 am
Posts: 3
Hey any answers?? .


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 9:20 am 
Beginner
Beginner

Joined: Fri Apr 16, 2004 10:25 am
Posts: 44
Location: Brazil
You want to detect the assocations at runtime and if any child is found I have to throw a exception?

Why don't you verify that in your code and throw a exception? Is it some kind of cascade delete with warning you want to do?


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.