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.

    Details

    • 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:

      Description

      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

          Activity

          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 4h 34m 1 Oliver Gierke 06/Mar/15 10:35 AM
          Resolved Resolved Closed Closed
          4d 16m 1 Oliver Gierke 10/Mar/15 11:52 AM

            People

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

              Dates

              • Created:
                Updated:
                Resolved: