openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgras...@apache.org
Subject svn commit: r1529292 - in /openjpa/branches/2.1.x: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-kernel/src/main/java/org/apache/openjpa/conf/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/
Date Fri, 04 Oct 2013 20:46:30 GMT
Author: jgrassel
Date: Fri Oct  4 20:46:30 2013
New Revision: 1529292

URL: http://svn.apache.org/r1529292
Log:
OPENJPA-2414: FinderCache does not consider active Fetch Groups/FetchPlan added Fields

Modified:
    openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderCacheImpl.java
    openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java
    openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java
    openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java
    openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java

Modified: openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderCacheImpl.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderCacheImpl.java?rev=1529292&r1=1529291&r2=1529292&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderCacheImpl.java
(original)
+++ openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderCacheImpl.java
Fri Oct  4 20:46:30 2013
@@ -108,8 +108,7 @@ public class FinderCacheImpl 
             return null;
         }
         
-        // FinderCache only operates with Default Fetch Plans
-        if (!fetch.isDefaultPUFetchGroupConfigurationOnly()) {
+        if (!fetch.isFetchConfigurationSQLCacheAdmissible()) {
             return null;
         }
         
@@ -151,8 +150,7 @@ public class FinderCacheImpl 
                 return null;
             }
             
-            // FinderCache only operates with Default Fetch Plans
-            if (!fetch.isDefaultPUFetchGroupConfigurationOnly()) {
+            if (!fetch.isFetchConfigurationSQLCacheAdmissible()) {
                 return null;
             }
             

Modified: openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java?rev=1529292&r1=1529291&r2=1529292&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java
(original)
+++ openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java
Fri Oct  4 20:46:30 2013
@@ -74,6 +74,7 @@ public class Compatibility {
     private boolean _filterPCRegistryClasses = false; // OPENJPA-2288
     private boolean _useListAttributeForArrays = true;
     private boolean _returnNullOnEmptyAggregateResult = false;   // OPENJPA-1794
+    private boolean _cacheNonDefaultFetchPlanQueries = false; // OPENJPA-2414
 
     /**
      * Whether to require exact identity value types when creating object
@@ -716,5 +717,21 @@ public class Compatibility {
     public void setReturnNullOnAggregateResult(boolean returnNullOnEmptyAggregateResult)
{
         _returnNullOnEmptyAggregateResult = returnNullOnEmptyAggregateResult;
     }
+    
+    /**
+     * Whether the SQL generated for queries executed with a modified fetch plan are cached.
+     * 
+     */
+    public boolean  getCacheNonDefaultFetchPlanQueries() {
+        return _cacheNonDefaultFetchPlanQueries;
+    }
+    
+    /**
+     * Whether the SQL generated for queries executed with a modified fetch plan are cached.
+     * 
+     */
+    public void setCacheNonDefaultFetchPlanQueries(boolean bool) {
+        _cacheNonDefaultFetchPlanQueries = bool;
+    }
 }
 

Modified: openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java?rev=1529292&r1=1529291&r2=1529292&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java
(original)
+++ openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java
Fri Oct  4 20:46:30 2013
@@ -595,4 +595,12 @@ public class DelegatingFetchConfiguratio
             throw translate(re);
         }
     }
+    
+    public boolean isFetchConfigurationSQLCacheAdmissible() {
+        try {
+            return _fetch.isFetchConfigurationSQLCacheAdmissible();
+        } catch (RuntimeException re) {
+            throw translate(re);
+        }
+    }
 }

Modified: openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java?rev=1529292&r1=1529291&r2=1529292&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java
(original)
+++ openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java
Fri Oct  4 20:46:30 2013
@@ -474,4 +474,10 @@ public interface FetchConfiguration
      * 
      */
     public boolean isDefaultPUFetchGroupConfigurationOnly();
+    
+    /**
+     * Whether SQL generated by the FetchConfiguration's current configuration should be
cached.
+     * 
+     */
+    public boolean isFetchConfigurationSQLCacheAdmissible();
 }

Modified: openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java?rev=1529292&r1=1529291&r2=1529292&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
(original)
+++ openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
Fri Oct  4 20:46:30 2013
@@ -148,7 +148,8 @@ public class FetchConfigurationImpl
         public boolean fetchGroupIsPUDefault = false;
         public boolean extendedPathLookup = false;
         public DataCacheRetrieveMode cacheRetrieveMode = DataCacheRetrieveMode.USE;
-        public DataCacheStoreMode cacheStoreMode = DataCacheStoreMode.USE;        
+        public DataCacheStoreMode cacheStoreMode = DataCacheStoreMode.USE;
+        public boolean cacheNonDefaultFetchPlanQueries = false;
     }
 
     private final ConfigurationState _state;
@@ -190,6 +191,8 @@ public class FetchConfigurationImpl
         clearFetchGroups();
         addFetchGroups(Arrays.asList(conf.getFetchGroupsList()));
         setMaxFetchDepth(conf.getMaxFetchDepth());
+        
+        _state.cacheNonDefaultFetchPlanQueries = conf.getCompatibilityInstance().getCacheNonDefaultFetchPlanQueries();
     }
 
     /**
@@ -198,6 +201,7 @@ public class FetchConfigurationImpl
     public Object clone() {
         FetchConfigurationImpl clone = newInstance(null);
         clone._state.ctx = _state.ctx;
+        clone._state.cacheNonDefaultFetchPlanQueries = _state.cacheNonDefaultFetchPlanQueries;
         clone._parent = _parent;
         clone._fromField = _fromField;
         clone._fromType = _fromType;
@@ -464,6 +468,15 @@ public class FetchConfigurationImpl
     public boolean isDefaultPUFetchGroupConfigurationOnly() {
         return _state.fetchGroupIsPUDefault;
     }
+    
+    public boolean isFetchConfigurationSQLCacheAdmissible() {
+        if (_state == null || _state.cacheNonDefaultFetchPlanQueries) {
+            return true;
+        } else {
+            // Only pctx-default matching FetchConfiguration generated SQL is cache permissible
+            return _state.fetchGroupIsPUDefault;
+        }
+    }
 
     public Set<String> getFields() {
         if (_state.fields == null) return Collections.emptySet();
@@ -501,6 +514,7 @@ public class FetchConfigurationImpl
                 _state.fields = new HashSet<String>();
             _state.fields.addAll(fields);
         } finally {
+            verifyDefaultPUFetchGroups();
             unlock();
         }
         return this;



Mime
View raw message