openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r728753 - in /openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc: meta/strats/StoreCollectionFieldStrategy.java sql/SQLBuffer.java
Date Mon, 22 Dec 2008 19:41:35 GMT
Author: faywang
Date: Mon Dec 22 11:41:35 2008
New Revision: 728753

URL: http://svn.apache.org/viewvc?rev=728753&view=rev
Log:
OPENJPA-838: remove cache from StoreCollectionFieldStrategy

Modified:
    openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java
    openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java

Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java?rev=728753&r1=728752&r2=728753&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java
(original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java
Mon Dec 22 11:41:35 2008
@@ -26,11 +26,8 @@
 import java.util.Map;
 
 import org.apache.openjpa.enhance.PersistenceCapable;
-import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
-import org.apache.openjpa.jdbc.kernel.JDBCFetchConfigurationImpl;
 import org.apache.openjpa.jdbc.kernel.JDBCStore;
-import org.apache.openjpa.jdbc.kernel.JDBCStoreManager;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.meta.FieldMapping;
 import org.apache.openjpa.jdbc.meta.FieldStrategy;
@@ -38,14 +35,11 @@
 import org.apache.openjpa.jdbc.schema.Column;
 import org.apache.openjpa.jdbc.schema.ForeignKey;
 import org.apache.openjpa.jdbc.sql.Joins;
-import org.apache.openjpa.jdbc.sql.LogicalUnion;
 import org.apache.openjpa.jdbc.sql.Result;
 import org.apache.openjpa.jdbc.sql.Select;
 import org.apache.openjpa.jdbc.sql.SelectExecutor;
-import org.apache.openjpa.jdbc.sql.SelectImpl;
 import org.apache.openjpa.jdbc.sql.Union;
 import org.apache.openjpa.kernel.OpenJPAStateManager;
-import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.meta.JavaTypes;
@@ -526,94 +520,19 @@
             return;
         }
 
-        //cache union for field here
         // select data for this sm
-        boolean found = true;
         final ClassMapping[] elems = getIndependentElementMappings(true);
         final Joins[] resJoins = new Joins[Math.max(1, elems.length)];
-        List parmList = null;
-        Union union = null;
-        SelectImpl sel = null;
-        Map<JDBCStoreManager.SelectKey, Object[]> storeCollectionUnionCache = null;
-        JDBCStoreManager.SelectKey selKey = null;
-        if (!((JDBCStoreManager)store).isQuerySQLCacheOn() || elems.length > 1)
-            union = newUnion(sm, store, fetch, elems, resJoins);
-        else {
-            parmList = new ArrayList();
-            JDBCFetchConfiguration fetchClone = new JDBCFetchConfigurationImpl();
-            fetchClone.copy(fetch);
-           
-            // to specify the type so that no cast is needed
-            storeCollectionUnionCache = ((JDBCStoreManager)store).
-                getCacheMapFromQuerySQLCache(StoreCollectionFieldStrategy.class);
-            selKey = 
-                new JDBCStoreManager.SelectKey(null, field, fetchClone);
-            Object[] objs = storeCollectionUnionCache.get(selKey);
-            if (objs != null) {
-                union = (Union) objs[0];
-                resJoins[0] = (Joins) objs[1];
-            }
-            else {
-                synchronized(storeCollectionUnionCache) {
-                    objs = storeCollectionUnionCache.get(selKey);
-                    if (objs == null) {
-                        // select data for this sm
-                        union = newUnion(sm, store, fetch, elems, resJoins);
-                        found = false;
-                    } else {
-                        union = (Union) objs[0];
-                        resJoins[0] = (Joins) objs[1];
-                    }
-
-                    sel = ((LogicalUnion.UnionSelect)union.getSelects()[0]).
-                        getDelegate();
-                    if (sel.getSQL() == null) {
-                    	((SelectImpl)sel).setSQL(store, fetch);
-                        found = false;
-                    }
-
-                    // only cache the union when elems length is 1 for now
-                    if (!found) { 
-                        Object[] objs1 = new Object[2];
-                        objs1[0] = union;
-                        objs1[1] = resJoins[0];
-                        ((JDBCStoreManager)store).addToSqlCache(
-                            storeCollectionUnionCache, selKey, objs1);
-                     }
-                }
-            }
-            
-            Log log = store.getConfiguration().
-                getLog(JDBCConfiguration.LOG_JDBC);
-            if (log.isTraceEnabled()) {
-                if (found)
-                    log.trace(_loc.get("cache-hit", field, this.getClass()));
-                else
-                    log.trace(_loc.get("cache-missed", field, this.getClass())); 
-            }
-            
-            ClassMapping mapping = field.getDefiningMapping();
-            Object oid = sm.getObjectId();
-            
-            if (sel == null)
-                sel = ((LogicalUnion.UnionSelect)union.getSelects()[0]).
-                getDelegate();
-           
-            ValueMapping embed = mapping.getEmbeddingMapping();
-            if (embed != null) 
-                mapping = getOwner(embed);
-
-            if (mapping != null) {
-                Column[] cols = mapping.getPrimaryKeyColumns();
-                sel.wherePrimaryKey(mapping, cols, cols, oid, store, 
-                    null, null, parmList);
+        Union union = store.getSQLFactory().newUnion
+            (Math.max(1, elems.length));
+        union.select(new Union.Selector() {
+            public void select(Select sel, int idx) {
+                ClassMapping elem = (elems.length == 0) ? null : elems[idx];
+                resJoins[idx] = selectAll(sel, elem, sm, store, fetch,
+                    JDBCFetchConfiguration.EAGER_PARALLEL);
             }
+        });
 
-            List nonFKParams = sel.getSQL().getNonFKParameters();
-            if (nonFKParams != null && nonFKParams.size() > 0) 
-                parmList.addAll(nonFKParams);
-        }
-        
         // create proxy
         Object coll;
         ChangeTracker ct = null;
@@ -626,7 +545,7 @@
         }
 
         // load values
-        Result res = union.execute(store, fetch, parmList);
+        Result res = union.execute(store, fetch);
         try {
             int seq = -1;
             while (res.next()) {
@@ -649,32 +568,7 @@
         else
             sm.storeObject(field.getIndex(), coll);
     }
-    
-    private ClassMapping getOwner(ValueMapping embed) {
-        if (embed == null)
-            return null;
-        ClassMapping owner = embed.getFieldMapping().getDefiningMapping();
-        if (owner.getPrimaryKeyFields().length > 0)
-            return owner;
-        ValueMapping embed1 = (ValueMapping) owner.getEmbeddingMetaData();
-        return getOwner(embed1);
-    }
 
-    protected Union newUnion(final OpenJPAStateManager sm, final JDBCStore store,
-        final JDBCFetchConfiguration fetch, final ClassMapping[] elems,
-        final Joins[] resJoins) {
-        Union union = store.getSQLFactory().newUnion
-        (Math.max(1, elems.length));
-        union.select(new Union.Selector() {
-            public void select(Select sel, int idx) {
-                ClassMapping elem = (elems.length == 0) ? null : elems[idx];
-                resJoins[idx] = selectAll(sel, elem, sm, store, fetch,
-                        JDBCFetchConfiguration.EAGER_PARALLEL);
-            }
-        });
-        return union;
-    }
-    
     /**
      * Select data for loading, starting in field table.
      */

Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java?rev=728753&r1=728752&r2=728753&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java
(original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java
Mon Dec 22 11:41:35 2008
@@ -56,7 +56,6 @@
     private List _subsels = null;
     private List _params = null;
     private List _cols = null;
-    private List _nonFKParams = null;
 
     /**
      * Default constructor.
@@ -147,11 +146,6 @@
                         _cols.add(paramIndex, null);
             }
         }
-        if (buf._nonFKParams != null) {
-            if (_nonFKParams == null)
-                _nonFKParams = new ArrayList();
-            _nonFKParams.addAll(buf._nonFKParams);
-        }
     }
 
     public SQLBuffer append(Table table) {
@@ -271,11 +265,6 @@
                 if (isFK)
                     break;
             }
-            if (!isFK) {
-                if (_nonFKParams == null)
-                    _nonFKParams = new ArrayList();
-                _nonFKParams.add(o);                
-            }
         }
         return this;
     }
@@ -399,9 +388,6 @@
         return (_params == null) ? Collections.EMPTY_LIST : _params;
     }
 
-    public List getNonFKParameters() {
-        return (_nonFKParams == null) ? Collections.EMPTY_LIST : _nonFKParams;
-    }
     /**
      * Return the SQL for this buffer.
      */



Mime
View raw message