-->
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.  [ 1 post ] 
Author Message
 Post subject: Business Validation and Hibernate teory...
PostPosted: Tue Mar 04, 2008 7:54 am 
Newbie

Joined: Wed Feb 09, 2005 11:15 am
Posts: 7
Location: Argentina
Hi people,

I want to throw this question that is not very clear for me, and I need some opinions on the subject.

The topic is as follows:

Im working with Hibernate 3 and i have in my domain model classes (User Event, Country, State, City)... With their respective relationships.

The doubt comes because I am doing a CRUD of these entities and when i have to delete a country, i have to validate that the country is not subject to any other object associated...eg Event, User , and so on.

Now I have to do this two approaches ...

1 - Get each of the objects that contain the entity to eliminate (Country), and check that there is no association ...

Code:
if (!Evento.getPais (). Equals (paisAEliminar)) { ....
   ... validation message.
}


and so with each of my objects in the domain model Country have ...
which is a long and tedious process ... and the performante is poor...

Or, ...

2 - Directly delete the country and leave the BD check for violation of the constraints. (In this case the issue is complicated to know who was really what happened ... because the BD launch a ¿XXXJDBCException? ...
That will be cached by Hibernate wrapper and later to one of its exceptions...


My Point is ...
Which of the two approaches used, preferred and / or I advise you ...
Is there any other way to perform these validations business ...??

many thanks to all ...

Mauro.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.