Skip to content

How to implement Pessimistic Locking with JPA [SPR-3812] #8492

Closed

Description

@spring-projects-issues

Satish havannavar opened SPR-3812 and commented

Hi i am Using following setup

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 "


Issue Links:

7 votes, 11 watchers

Activity

  1. spring-projects-issues commented on Sep 28, 2007

    @spring-projects-issues
    CollaboratorAuthor

    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

  2. spring-projects-issues commented on May 5, 2009

    @spring-projects-issues
    CollaboratorAuthor

    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?

  3. spring-projects-issues commented on May 6, 2009

    @spring-projects-issues
    CollaboratorAuthor

    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

  4. spring-projects-issues commented on May 19, 2011

    @spring-projects-issues
    CollaboratorAuthor

    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.

  5. spring-projects-issues commented on May 20, 2011

    @spring-projects-issues
    CollaboratorAuthor

    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

  6. spring-projects-issues commented on May 20, 2011

    @spring-projects-issues
    CollaboratorAuthor

    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)?

  7. spring-projects-issues commented on Aug 9, 2014

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Addressed for Hibernate EntityManager 4 in #16559.

  8. added
    type: enhancement
    in: core
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions