You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to implement Pessimistic Locking with JPA [SPR-3812] #8492
Spring version 2.0.5 jar
[b]Hibernate version:3.2
Hibernate-annotations- version 3.3.0.ga.jar
Hibernate-entityManager version 3.3.1ga.jar
when i am trying to to lock a row using the annotation @Transactional(isolation = Isolation.SERIALIZABLE) in Manager giving me the error
"Standard JPA does not support custom isolation levels - use a special JpaDialect "
As the exception says, standard JPA does not support custom isolation levels. Unfortunately, none of the existing JpaDialects supports this feature either. We need to research what we can do for specific JPA providers there, but generally speaking, you won't be able to rely on custom isolation levels being available when you use JPA.
Standard JPA does not support custom isolation levels, because the JTA specifies it. So the truth is that Spring does not support transaction isolation with JPA?
Well, standard JTA does not define an isolation level concept either, because isolation levels are primarily a relational database concept - and JTA is a generic transaction API without any specific support for relational databases. The term "isolation" is not even mentioned in the JTA spec.
That said: Some JTA providers - e.g. WebLogic's - allow for specifying an isolation level that then gets applied to all JDBC Connections that are obtained during a specific transaction. That will generally work with JPA as well, when used within such a WebLogic JTA transaction.
However, for native JPA transactions, there is simply no support for isolation levels in any of the present providers. I'm happy to learn about any news there; Spring will be supporting these features as they emerge. However, fundamentally, we're limited by what the underlying JPA provider allows us to do.
Note that the above solution on stackoverflow does not account for the clean up step. In the clean up step the isolation level of the connection instance should be set back to the previous one.
Hi,
To my opinion, jta must not be tight coupled with jpa provider, they are totally discosiated. A simple documentation on the use of atomikos , jotm or jee server do the trick according to the rules with no friction at all.
I didn't understand the link between JPA, JTA and the current topic. One is a persistence api and another one is an transaction API and this topic is about enabling isolation levels on the connection used in the transaction. It would be helpful if you could elaborate on these concepts.
Also do you have any suggestions on the workaround to resolve the current problem of setting isolation level on the connection when the transaction is started (other then the above one on stackoverflow which is incomplete and has a lot of dependency on hibernate/spring code)?
Activity
spring-projects-issues commentedon Sep 28, 2007
Juergen Hoeller commented
As the exception says, standard JPA does not support custom isolation levels. Unfortunately, none of the existing JpaDialects supports this feature either. We need to research what we can do for specific JPA providers there, but generally speaking, you won't be able to rely on custom isolation levels being available when you use JPA.
Juergen
spring-projects-issues commentedon May 5, 2009
Robert Kristofic commented
Standard JPA does not support custom isolation levels, because the JTA specifies it. So the truth is that Spring does not support transaction isolation with JPA?
spring-projects-issues commentedon May 6, 2009
Juergen Hoeller commented
Well, standard JTA does not define an isolation level concept either, because isolation levels are primarily a relational database concept - and JTA is a generic transaction API without any specific support for relational databases. The term "isolation" is not even mentioned in the JTA spec.
That said: Some JTA providers - e.g. WebLogic's - allow for specifying an isolation level that then gets applied to all JDBC Connections that are obtained during a specific transaction. That will generally work with JPA as well, when used within such a WebLogic JTA transaction.
However, for native JPA transactions, there is simply no support for isolation levels in any of the present providers. I'm happy to learn about any news there; Spring will be supporting these features as they emerge. However, fundamentally, we're limited by what the underlying JPA provider allows us to do.
Juergen
spring-projects-issues commentedon Mar 9, 2011
Hans Desmet commented
You can find an example solution on
http://stackoverflow.com/questions/5234240/hibernatespringjpaisolation-does-not-work (example class HibernateExtendedJpaDialect)
spring-projects-issues commentedon May 19, 2011
Amit commented
Note that the above solution on stackoverflow does not account for the clean up step. In the clean up step the isolation level of the connection instance should be set back to the previous one.
spring-projects-issues commentedon May 20, 2011
Charlie Mordant commented
Hi,
To my opinion, jta must not be tight coupled with jpa provider, they are totally discosiated. A simple documentation on the use of atomikos , jotm or jee server do the trick according to the rules with no friction at all.
Regards, Charlie
spring-projects-issues commentedon May 20, 2011
Amit commented
I didn't understand the link between JPA, JTA and the current topic. One is a persistence api and another one is an transaction API and this topic is about enabling isolation levels on the connection used in the transaction. It would be helpful if you could elaborate on these concepts.
Also do you have any suggestions on the workaround to resolve the current problem of setting isolation level on the connection when the transaction is started (other then the above one on stackoverflow which is incomplete and has a lot of dependency on hibernate/spring code)?
spring-projects-issues commentedon Aug 9, 2014
Juergen Hoeller commented
Addressed for Hibernate EntityManager 4 in #16559.