openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curti...@apache.org
Subject svn commit: r1055524 - /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
Date Wed, 05 Jan 2011 16:58:33 GMT
Author: curtisr7
Date: Wed Jan  5 16:58:33 2011
New Revision: 1055524

URL: http://svn.apache.org/viewvc?rev=1055524&view=rev
Log:
OPENJPA-1917: Cache column alias.

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java?rev=1055524&r1=1055523&r2=1055524&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java Wed
Jan  5 16:58:33 2011
@@ -2319,6 +2319,7 @@ public class SelectImpl
         implements PathJoins {
 
         private SelectImpl _sel = null;
+        private Map<Column, Object> cachedColumnAlias_ = null;
 
         // position in selected columns list where we expect the next load
         private int _pos = 0;
@@ -2399,8 +2400,15 @@ public class SelectImpl
             // we key directly on objs and join-less cols, or on the alias
             // for cols with joins
             PathJoins pj = getJoins(joins);
-            if (pj != null && pj.path() != null)
-                obj = getColumnAlias((Column) obj, pj);
+            if (pj != null && pj.path() != null) {
+                Object columnAlias = getColumnAlias((Column) obj, pj);
+                if (joins == null) {
+                    if (cachedColumnAlias_ == null)
+                        cachedColumnAlias_ = new HashMap<Column, Object>();
+                    cachedColumnAlias_.put((Column) obj, columnAlias);
+                }
+                return columnAlias != null && _sel._selects.contains(columnAlias);
+            }
             return obj != null && _sel._selects.contains(obj);
         }
 
@@ -2449,7 +2457,13 @@ public class SelectImpl
             if (pj != null && pj.path() != null) {
                 Column col = (Column) obj;
                 pk = (col.isPrimaryKey()) ? Boolean.TRUE : Boolean.FALSE;
-                obj = getColumnAlias(col, pj);
+                if (joins == null && cachedColumnAlias_ != null) {
+                    obj = cachedColumnAlias_.get(col);
+                    if (obj == null)
+                        obj = getColumnAlias(col, pj);
+                } else {
+                    obj = getColumnAlias(col, pj);
+                }
                 if (obj == null)
                     throw new SQLException(col.getTable() + ": "
                         + pj.path() + " (" + _sel._aliases + ")");



Mime
View raw message