openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r1236326 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-kernel/src/main/java/org/apache/openjpa/meta/ openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/
Date Thu, 26 Jan 2012 17:56:13 GMT
Author: ppoddar
Date: Thu Jan 26 17:56:12 2012
New Revision: 1236326

URL: http://svn.apache.org/viewvc?rev=1236326&view=rev
Log:
OPENJPA-2116: Optimize frequent operations  a) field denotes a relation and b) schema name
needs conversion.

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierUtilImpl.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java?rev=1236326&r1=1236325&r2=1236326&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
Thu Jan 26 17:56:12 2012
@@ -816,7 +816,7 @@ public class FetchConfigurationImpl
         if (!includes(fm))
             return FETCH_NONE;
         
-        Class<?> type = getRelationType(fm);
+        Class<?> type = fm.getRelationType();
         if (type == null)
             return FETCH_LOAD;
         if (_availableDepth == 0)
@@ -842,7 +842,7 @@ public class FetchConfigurationImpl
     }
 
     public FetchConfiguration traverse(FieldMetaData fm) {
-        Class<?> type = getRelationType(fm);
+        Class<?> type = fm.getRelationType();
         if (type == null)
             return this;
 
@@ -943,18 +943,6 @@ public class FetchConfigurationImpl
         return Math.min(max, avail);
     }
 
-    /**
-     * Return the relation type of the given field.
-     */
-    private static Class<?> getRelationType(FieldMetaData fm) {
-        if (fm.isDeclaredTypePC())
-            return fm.getDeclaredType();
-        if (fm.getElement().isDeclaredTypePC())
-            return fm.getElement().getDeclaredType();
-        if (fm.getKey().isDeclaredTypePC())
-            return fm.getKey().getDeclaredType();
-        return null;
-    }
 
     /**
      * Reduce the given logical depth by 1.

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java?rev=1236326&r1=1236325&r2=1236326&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java
Thu Jan 26 17:56:12 2012
@@ -2390,5 +2390,19 @@ public class FieldMetaData
     public void setPersistentCollection(boolean persistentCollection) {
         _persistentCollection = persistentCollection;
     }
-    
+    private Class<?> _relationType = Unknown.class;
+    public Class<?> getRelationType() {
+    	if (_relationType == Unknown.class) {
+            if (isDeclaredTypePC())
+            	_relationType = getDeclaredType();
+            else if (getElement().isDeclaredTypePC())
+            	_relationType = getElement().getDeclaredType();
+            else if (getKey().isDeclaredTypePC())
+            	_relationType = getKey().getDeclaredType();
+            else
+            	_relationType = null;
+    	}
+    	return _relationType;
+    }
+    private class Unknown{};
 }

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierUtilImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierUtilImpl.java?rev=1236326&r1=1236325&r2=1236326&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierUtilImpl.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierUtilImpl.java
Thu Jan 26 17:56:12 2012
@@ -542,7 +542,8 @@ public class IdentifierUtilImpl implemen
 
 
     protected boolean needsConversion(IdentifierConfiguration config) {
-        return !(config.getConversionKey().equals(getIdentifierConfiguration().getConversionKey()));
+    	return (config != getIdentifierConfiguration()) 
+           && !(config.getConversionKey().equals(getIdentifierConfiguration().getConversionKey()));
     }
 
     private IdentifierRule[] getNamingRules(String[] rules) {



Mime
View raw message