OpenJPA
  1. OpenJPA
  2. OPENJPA-1532

Should the <shared-cache-mode> element in a persistence unit definition automatically turn on the data cache?

    Details

    • Type: Question Question
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.0, 2.1.0, 2.2.0
    • Fix Version/s: 2.2.2, 2.3.0
    • Component/s: datacache
    • Labels:
      None

      Description

      The JPA 2.0 spec introduces a new persistence unit definition element, <shared-cache-mode>, which accepts NONE, ALL, ENABLE_SELECTIVE, and DISABLE_SELECTIVE. The JPA 2.0 spec section 3.7.1 documents the behavior of each of those modes.

      What I am curious about is if the use of <shared-cache-mode> should implicitly enable OpenJPA's data cache plugin. Currently, the above element is completely ignored if the persistence unit is missing the properties: openjpa.DataCache=true and openjpa.RemoteCommitProvider=sjvm (because by default, OpenJPA disables data caching). My interpretation of the spec suggests that <shared-cache-mode> is not only a platform-independent method of instructing the data cache which entities are eligible for admittance to the data cache, but it is also a switch providing a platform-independent method of both turning the data cache on or off (since whether the cache is enabled by default is platform-specific). Otherwise, why have a NONE value, if it was not intended to be a platform independent means of turning the data cache off?

      1. OPENJPA-1532.patch.txt
        19 kB
        Michael Dick
      2. OPENJPA-1532.patch
        56 kB
        Helen Xu
      3. OPENJPA-1532-Doc.patch
        4 kB
        Helen Xu
      4. OPENJPA-1532-MigrationDoc.patch
        1 kB
        Helen Xu

        Activity

        Hide
        Helen Xu added a comment -

        Migration doc added to 2.2.x and trunk.

        Show
        Helen Xu added a comment - Migration doc added to 2.2.x and trunk.
        Hide
        Helen Xu added a comment -

        reopen the issue to attach the migration doc

        Show
        Helen Xu added a comment - reopen the issue to attach the migration doc
        Hide
        Rick Curtis added a comment -

        Committed test/code to trunk.

        Thanks for the patch Helen!

        Show
        Rick Curtis added a comment - Committed test/code to trunk. Thanks for the patch Helen!
        Hide
        Helen Xu added a comment -

        Attached a fix to this issue. The fix is similar to what Michael had, but in different class when all the properties are loaded in PersistenceProductDerivation. Also add more messages to indicate the config conflicts and give recommendation.
        New test cases are added to have a better coverage.
        Modified the existing doc to include the integration of the shared cache mode and openjpa.DataCache

        Show
        Helen Xu added a comment - Attached a fix to this issue. The fix is similar to what Michael had, but in different class when all the properties are loaded in PersistenceProductDerivation. Also add more messages to indicate the config conflicts and give recommendation. New test cases are added to have a better coverage. Modified the existing doc to include the integration of the shared cache mode and openjpa.DataCache
        Hide
        Pinaki Poddar added a comment -

        Whether <shared-cache-mode> activates data cache or not – is not the issue I have raised. In fact I tend to agree that shared-cache-mode should activate Data Cache. My concern is how it is to be done.doing it in a case-by-case basis is weaker design construct. A design to support co-dependent configuration should be followed.

        Show
        Pinaki Poddar added a comment - Whether <shared-cache-mode> activates data cache or not – is not the issue I have raised. In fact I tend to agree that shared-cache-mode should activate Data Cache. My concern is how it is to be done.doing it in a case-by-case basis is weaker design construct. A design to support co-dependent configuration should be followed.
        Hide
        Michael Dick added a comment -

        Attaching a patch which partially resolves this issue. I wouldn't consider it finished though.

        Specifically the patch sets openjpa.DataCache and openjpa.RemoteCommitProvider to the most basic values if :
        1. They are not already provided in persistence.xml or passed in when the EMF is created
        2. shared-cache-mode is not NONE

        There's still work to be done to resolve conflicts, (eg shared-cache-mode = ALL and openjpa.DataCache=false), and there may be a cleaner way to handle the properties, but at least it's a starting point.

        Show
        Michael Dick added a comment - Attaching a patch which partially resolves this issue. I wouldn't consider it finished though. Specifically the patch sets openjpa.DataCache and openjpa.RemoteCommitProvider to the most basic values if : 1. They are not already provided in persistence.xml or passed in when the EMF is created 2. shared-cache-mode is not NONE There's still work to be done to resolve conflicts, (eg shared-cache-mode = ALL and openjpa.DataCache=false), and there may be a cleaner way to handle the properties, but at least it's a starting point.
        Hide
        Kevin Sutter added a comment -

        Absolutely, the JPA 2 <shared-cache-mode> element should affect the existing OpenJPA DataCache enablement. That should be part of the integration work. I am reading the spec like you are and the <shared-cache-mode> affects whether to use an L2 cache for caching entities or not. I read that to mean that it should also affect the enablement of the cache. Unless we can find something in the spec that indicates otherwise, I would say that this is a bug.

        Show
        Kevin Sutter added a comment - Absolutely, the JPA 2 <shared-cache-mode> element should affect the existing OpenJPA DataCache enablement. That should be part of the integration work. I am reading the spec like you are and the <shared-cache-mode> affects whether to use an L2 cache for caching entities or not. I read that to mean that it should also affect the enablement of the cache. Unless we can find something in the spec that indicates otherwise, I would say that this is a bug.

          People

          • Assignee:
            Rick Curtis
            Reporter:
            Jody Grassel
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development