You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by knak55 <KN...@pngjudiciary.gov.pg> on 2012/11/01 06:35:04 UTC

Re: How can I catch OptimisticLockException?

Thank you Romain,

I can handle OptimisticLockException by calling flush() after causing the
exception as you mentioned.
Thank you for your help.
However I do not know why Glassfish does not have to call it. Checking the
flush mode, I found out both Glasshfish and TomEE use "AUTO" mode.
Incidentally I also found out if I do not call flush(), I cannot catch the
exception inside the function in Stateless Session EJB but can catch it
outside, in my case inside CDI. However in case of Glassfish, I can catch
the exception inside the function in Stateless Session EJB even if I do not
call flush().

Many Thanks



--
View this message in context: http://openejb.979440.n4.nabble.com/How-can-I-catch-OptimisticLockException-tp4658313p4658339.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: How can I catch OptimisticLockException?

Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
Glassfish is actually using the reference implementation (eclipse link). It
seems to not work the same way as Hibernate or other.
Maybe, it's flushing by default for any changes whereas Hibernate tends to
get as much as possible changes in the PersistenceContext and only flush
when relevant or at the end of the transaction.
The Hibernate documentation is pretty clear on that point.

Anyway thanks for the feedback.

JLouis


2012/11/1 knak55 <KN...@pngjudiciary.gov.pg>

> Thank you Romain,
>
> I can handle OptimisticLockException by calling flush() after causing the
> exception as you mentioned.
> Thank you for your help.
> However I do not know why Glassfish does not have to call it. Checking the
> flush mode, I found out both Glasshfish and TomEE use "AUTO" mode.
> Incidentally I also found out if I do not call flush(), I cannot catch the
> exception inside the function in Stateless Session EJB but can catch it
> outside, in my case inside CDI. However in case of Glassfish, I can catch
> the exception inside the function in Stateless Session EJB even if I do not
> call flush().
>
> Many Thanks
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/How-can-I-catch-OptimisticLockException-tp4658313p4658339.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>