logic: database application/2 (constraints check)
this specific chronicle .
i wish check i am inserting register row. should i check programmatically concentration layer:
if (exists(obj))
{
pitch new duplicateobjectexception();
}
hibernatesessionfactory.getsession().save(obj);
or should i locate difference thrown database covering triggered i violate contraint?
try
{
hibernatesessionfactory.getsession().save(obj);
}
catch(constraintviolationexception e)
{
pitch new duplicateobjectexception();
}
edit: words: nonetheless imprisonment there sojourn (it's good database settlement anyway, i can't certain app wholly accessing table) shall i rest imprisonment hoop difference the defilement raise, i'd improved check anyway?
edit2: impetus i check+insert within transaction, locking list pledge slight minute another record meantime
Comments
Post a Comment