Spring Data JPA
  1. Spring Data JPA
  2. DATAJPA-183

SimpleJpaRepository should not declare @Transactional(readOnly=true) to support working with Extended PersistenceContext.


    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.0.3, 1.1 RC1
    • Fix Version/s: None
    • Component/s: Core
    • Labels:


      SimpleJpaRepository is annotated with @Transaction(readOnly = true).

      This means that every method declared on the interface is transactional. It simply makes spring-data-jpa unusable with the extended PersistenceContext, since even in query methods you have a transaction that flushes the PersistenceContext and detaches all the objects in it.

      I understand the benefits of using @Transaction(readOnly=true) in the "EntityManager per Transaction pattern". But I believe that this behavior should no be the default, or at least be configurable. I haven't found a simple way of "removing" this transactional behavior on the repositories.

      I believe that Spring Webflow + Extended PersistenceContext + Spring-Data-JPA is a great combination. But the default behavior prevents me from using it.

      The only workaround I found was to clone the code, remove the annotation and deploy it on my private repository. Everything is working fine with this "hack".


        No workflow transitions have been executed yet.


          • Assignee:
            Oliver Gierke
            Edson Yanaga
          • Votes:
            1 Vote for this issue
            1 Start watching this issue


            • Created: