openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awh...@apache.org
Subject svn commit: r645589 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps: GetMapValue.java JDBCExpressionFactory.java
Date Mon, 07 Apr 2008 16:18:27 GMT
Author: awhite
Date: Mon Apr  7 09:18:26 2008
New Revision: 645589

URL: http://svn.apache.org/viewvc?rev=645589&view=rev
Log:
Fix for OPENJPA-554.


Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/GetMapValue.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/GetMapValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/GetMapValue.java?rev=645589&r1=645588&r2=645589&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/GetMapValue.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/GetMapValue.java
Mon Apr  7 09:18:26 2008
@@ -45,15 +45,17 @@
 
     private final Val _map;
     private final Val _key;
+    private final String _alias;
     private ClassMetaData _meta = null;
     private Class _cast = null;
 
     /**
      * Constructor. Provide the map and key to operate on.
      */
-    public GetMapValue(Val map, Val key) {
+    public GetMapValue(Val map, Val key, String alias) {
         _map = map;
         _key = key;
+        _alias = alias;
     }
 
     public ClassMetaData getMetaData() {
@@ -111,7 +113,8 @@
 
     public void select(Select sel, ExpContext ctx, ExpState state, 
         boolean pks) {
-        sel.select(newSQLBuffer(sel, ctx, state), this);
+        sel.select(newSQLBuffer(sel, ctx, state).append(" AS ").append(_alias),
+            this);
     }
 
     public void selectColumns(Select sel, ExpContext ctx, ExpState state,
@@ -127,7 +130,7 @@
 
     public void orderBy(Select sel, ExpContext ctx, ExpState state, 
         boolean asc) {
-        sel.orderBy(newSQLBuffer(sel, ctx, state), asc, false);
+        sel.orderBy(_alias, asc, false);
     }
 
     private SQLBuffer newSQLBuffer(Select sel, ExpContext ctx, ExpState state) {

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java?rev=645589&r1=645588&r2=645589&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java
Mon Apr  7 09:18:26 2008
@@ -58,6 +58,7 @@
 
     private final ClassMapping _type;
     private final SelectConstructor _cons = new SelectConstructor();
+    private int _getMapValueAlias = 0;
 
     /**
      * Constructor. Supply the type we're querying against.
@@ -396,6 +397,7 @@
     }
 
     public Value getMapValue(Value map, Value arg) {
-        return new GetMapValue((Val) map, (Val) arg);
+        return new GetMapValue((Val) map, (Val) arg, 
+            "gmv" + _getMapValueAlias++);
     }
 }



Mime
View raw message