tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jean-Louis MONTEIRO <jeano...@gmail.com>
Subject Re: How can I catch OptimisticLockException?
Date Mon, 29 Oct 2012 11:47:08 GMT
There is no trivial way to get that in the client cause the spec requires
it to be wrapped.
As the exception is thrown during commit (flush at least), you can in the
business method (ie. the session bean method) force a em.flush() to
propagate the persistence context to the database and get all relational
constraints validated by the database.
Around the flush statement, you can catch the Optimistic Lock exception and
throw a business exception.

That's the best way from a design point of view to do and to deal with such
a situation.

Jean-Louis


2012/10/29 Romain Manni-Bucau <rmannibucau@gmail.com>

> hi,
>
> can you share the whole stack please?
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<
> http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
>
> 2012/10/29 knak55 <KNakagawa@pngjudiciary.gov.pg>
>
> > Hi,
> >
> > I am trying to migrate an application which works on Glassfish 3.1.2.2to
> > TomEE 1.5.
> > The application calls each component like this :  JSF -> CDI -> Stateless
> > EJB -> JPA -> DB
> > On the Glassfish, a program(CDI) in the web tire can handle the
> > “OptimisticLockException” with the following code successfully.
> >
> >         :
> > } catch  (Exception e) {
> >         if (e.getCause() instanceof
> > javax.persistence.OptimisticLockException) {
> >         :
> >
> > However, on the TomEE 1.5,  we got javax.transaction.RollbackException
> > instead of
> > javax.persistence.OptimisticLockException.
> >
> > How can I catch “OptimisticLockException” in the CDI?
> >
> >
> >
> > --
> > View this message in context:
> >
> http://openejb.979440.n4.nabble.com/How-can-I-catch-OptimisticLockException-tp4658313.html
> > Sent from the OpenEJB User mailing list archive at Nabble.com.
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message