-->
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.  [ 5 posts ] 
Author Message
 Post subject: Constraint violation on delete
PostPosted: Thu Nov 17, 2005 6:13 am 
Newbie

Joined: Thu Nov 17, 2005 6:02 am
Posts: 3
Location: Romania
I'm using Spring with Hibernate, I'm having a table, USERS, and another table PROJECTS. Each line in table PROJECTS is introduced by a USER. If I try to delete the user I get a foreign key violation error. What I'm trying to do is to give the user a message saying that the user cannot be deleted because it is used. Should be ok to do a simple query to check if that user exists in PROJECTS but there are like 10 tables like PROJECTS and could appear more.

My question is: is there a convenient way to find if an user is used in another table so that I will not do a query for each table?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 9:05 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
in constraint violation exception you have data about violated constraint - you have to explore this exception - it can depend from your database


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 1:15 pm 
Newbie

Joined: Thu Nov 17, 2005 6:02 am
Posts: 3
Location: Romania
No, the exception doesn't depend on the database, it's a Spring context. But the Spring exception was indeed the thing that helped me to solve the problem. ;)


snpesnpe wrote:
in constraint violation exception you have data about violated constraint - you have to explore this exception - it can depend from your database


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 2:17 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Quote:
No, the exception doesn't depend on the database

i don't tell it depend from database - i tell - it can depend (maybe depend) - my english is bad

it is important that you resolve problem


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 2:33 pm 
Newbie

Joined: Thu Nov 17, 2005 6:02 am
Posts: 3
Location: Romania
Yes, I solved the problem. I defined a throws advice and to it I wired a regular expressions advisor for generalizing the solution for all domains. Now it works.

snpesnpe wrote:
it is important that you resolve problem


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