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


          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Waiting for Feedback Waiting for Feedback
          932d 22h 58m 1 Oliver Gierke 17/Oct/14 7:01 AM
          Waiting for Feedback Waiting for Feedback Resolved Resolved
          140d 3h 34m 1 Oliver Gierke 06/Mar/15 10:35 AM
          Resolved Resolved Closed Closed
          4d 1h 16m 1 Oliver Gierke 10/Mar/15 11:52 AM


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


              • Created: