java - Hibernate flush and JTAUnexpectedRollbackException -
I am using Spring and Hibernate for transactions and atoms I use annotation based transactions I have a DAO object And in one of the ways I call entityManager.persist () to save the otag. Now whenever an ORA error occurs during the update, for example an infringement is violated or the definition of a greater than a database in the column is determined, I get JTAUnexpectedRollbackException instead of the generic JDBCcpsation which is thrown by spring is. I tried to make constant efforts to catch it, but I am not getting any exceptions. Hibernation actually makes actual updates during the flush, which happens during the transaction commitment and therefore unexpected rollback exposure I think
how can I get around this and the unexpected rollback exception Can I get generic JDBCCCC instead? Firstly, Disclaimer: I do not use atomicocos I do not believe that the error in the question is:
There is no connection, but surely this can not know.
I had a similar problem in the spring / hibernate application some time ago. Hibernate actually only transmits session updates to the database during flush. The problem is that flush can be on different time depending on flush mode. This is the default for auto
which means that a flush may occur before the query execution if the sessions are updated which can affect the query results. You have several options here:
A) You can call entityManager.persist ()
immediately after calling entityManager.flush ()
and catch exceptions (if any ) Negative side of that point at that point (which may not apply or apply to your case) It is) that the flush batch interrupts the update, so that you can experience multiple entries of a single unit type (potentially) important within the same transaction.
B) You can set your flush mode in the comma which is not committed until the transaction is committed (or until flush ()
is enforced manually ) After that, you can catch exceptions at that point or, if it proves impossible due to atomic, then you commit (just at the end of your service call), for example flush ()
Can invoke The downside is that this is a difficult option (it was difficult in my case, it can be very difficult with atomicos - I do not know) and your questions can potentially return stale data.
Comments
Post a Comment