This content has been marked as final.
Show 4 replies
-
1. Re: how to handle hibernate exceptions in ejb3
grdzeli_kaci Nov 7, 2009 6:09 AM (in response to grdzeli_kaci)can anybody help on this ?
i have big problem with this :(
_____________________
Regards,
Paata Lominadze.
Magticom LTD. -
2. Re: how to handle hibernate exceptions in ejb3
wolfgangknauf Nov 9, 2009 10:22 AM (in response to grdzeli_kaci)Hi,
probably you will have to catch the exceptions which are thrown when calling "entityManager.persist(...)", and in some inner exception you should find the hibernate exceptions and perform the appropriate handling.
Hope this helps
Wolfgang -
3. Re: how to handle hibernate exceptions in ejb3
grdzeli_kaci Nov 10, 2009 1:34 AM (in response to grdzeli_kaci)"Wolfgang Knauf" wrote:
Hi,
probably you will have to catch the exceptions which are thrown when calling "entityManager.persist(...)", and in some inner exception you should find the hibernate exceptions and perform the appropriate handling.
Hope this helps
Wolfgang
Thank you very much Wolfgang for your post.
I'll try to explain my case in details.
I have session bean with some operation:@Stateless @Remote(ContractFasade.class) public class ContractFasadeBean implements ContractFasade { @TransactionAttribute(TransactionAttributeType.REQUIRED) public void createContract(some parameteres .... ) throws MyException{ try{ // creating contract into my provisioning system (by WS Client, //Creating some file into file system and so on.) .......................................................................... // then creating contract into my databse(in my case - Oracle) oracleManager.persist(someEntity); oracleManager.merge(someOtherEntity); ........................................................................... // make some other business logic // also i tried to flush database, thought it can help to catch database exceptions. oracleManager.flush(); } catch(Exception e){ // catch any exceptions !!!!!!! // i need this case !!!!!!!!!!! // delete contract from my provisioning system. } } }
for some times may occurred hibernate exceptions for example :
ConstraintViolationException
LockAcquisitionException
and so on ...
It's impossible to handle this :(.
Exception occurred when CMT trying to commit database.
Is it possible to handle this ? or maybe I'm on wrong way and there is any other pattern for it ..
I can't find anything in the internet about it.
Thank you very much again.
_____________________
Regards,
Paata Lominadze.
Magticom LTD. -
4. Re: how to handle hibernate exceptions in ejb3
wolfgangknauf Nov 10, 2009 7:08 AM (in response to grdzeli_kaci)Hi,
what about something like this:catch(Exception e) { if (e.getCause() instanceof ConstraintViolationException) { ... } else if (e.getCause() instanceof LockAcquisitionException) { ... } //Maybe also check e.getCause().getCause() and so on! }
Hope this helps
Wolfgang