Hey I am newbie to Hibernate and I have the below issue.
What is the best way in Handling Referential Integrity ?
Actullay I have a code table which has entries different code types like state , country etcc.. Like id , code_type , value , description
I am using this general code as a property in many tables. In few places i have set many-to-one relationship . But in many places like country and state that doesnt make sense . So I am using this as normal property.
Also I have used foreign key relationship .
Now the problem comes at the time of deletion of a used code. Currenlty I am doing a delete and calling flush explicity . If any exception comes (ie JDBCException due to foreign key violation , I say that the code may be in use .
1 , Is this approach correct ??
2 , Any better appraoches??
3 , I want to know under what scenorias this may fail ?
Thanks and Regards
Vijay
|