Uploaded image for project: '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
    • Status: Closed
    • Priority: Major
    • Resolution: Works as Designed
    • 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".


          Issue Links



              • Assignee:
                olivergierke Oliver Gierke
                yanaga Edson Yanaga
                Last updater:
                Oliver Gierke
              • Votes:
                3 Vote for this issue
                5 Start watching this issue


                • Created: