openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r797257 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/ openjp...
Date Thu, 23 Jul 2009 23:01:55 GMT
Author: ppoddar
Date: Thu Jul 23 23:01:55 2009
New Revision: 797257

URL: http://svn.apache.org/viewvc?rev=797257&view=rev
Log:
OPENJPA-1195: Datastore function for in general usage as well as JPA 2.0. CriteriaQuery Parameter
indexing during registration.

Added:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/DatastoreFunction.java
  (with props)
Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Args.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/Args.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/ExpressionFactory.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/InMemoryExpressionFactory.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/CriteriaTest.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypesafeCriteria.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaBuilder.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaQueryImpl.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/Expressions.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/ParameterExpressionImpl.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Args.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Args.java?rev=797257&r1=797256&r2=797257&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Args.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Args.java
Thu Jul 23 23:01:55 2009
@@ -18,6 +18,10 @@
  */
 package org.apache.openjpa.jdbc.kernel.exps;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
 import org.apache.openjpa.jdbc.sql.Joins;
 import org.apache.openjpa.jdbc.sql.Result;
 import org.apache.openjpa.jdbc.sql.SQLBuffer;
@@ -43,18 +47,21 @@
      * Constructor. Supply values being combined.
      */
     public Args(Val val1, Val val2) {
-        int len1 = (val1 instanceof Args) ? ((Args) val1)._args.length : 1;
-        int len2 = (val2 instanceof Args) ? ((Args) val2)._args.length : 1;
-
-        _args = new Val[len1 + len2];
-        if (val1 instanceof Args)
-            System.arraycopy(((Args) val1)._args, 0, _args, 0, len1);
-        else
-            _args[0] = val1;
-        if (val2 instanceof Args)
-            System.arraycopy(((Args) val2)._args, 0, _args, len1, len2);
-        else
-            _args[len1] = val2;
+        this(new Val[]{val1, val2});
+    }
+    
+    public Args (Val... values) {
+        List<Val> list = new ArrayList<Val>();
+        if (values != null) {
+            for (Val v : values) {
+                if (v instanceof Args) {
+                    list.addAll(Arrays.asList(((Args)v)._args));
+                } else {
+                    list.add(v);
+                }
+            }
+        }
+        _args = list.toArray(new Val[list.size()]);
     }
 
     /**
@@ -166,6 +173,12 @@
 
     public void appendTo(Select sel, ExpContext ctx, ExpState state, 
         SQLBuffer sql, int index) {
+        ArgsExpState astate = (ArgsExpState) state;
+        for (int i = 0; i < _args.length; i++) {
+            _args[i].appendTo(sel, ctx, astate.states[i], sql, index);
+            if (i < _args.length-1)
+                sql.append(", ");
+        }
     }
 
     public void appendIsEmpty(Select sel, ExpContext ctx, ExpState state, 

Added: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/DatastoreFunction.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/DatastoreFunction.java?rev=797257&view=auto
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/DatastoreFunction.java
(added)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/DatastoreFunction.java
Thu Jul 23 23:01:55 2009
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.jdbc.kernel.exps;
+
+import org.apache.openjpa.kernel.exps.Arguments;
+
+/**
+ * A unary operator that executes a datastore specific function with zero or more arguments.
+ * 
+ * @author Pinaki Poddar
+ *
+ */
+@SuppressWarnings("serial")
+public class DatastoreFunction extends UnaryOp {
+    private final String _functionName;
+    
+    public DatastoreFunction(String name, Class<?> resultType, Arguments args) {
+        super((Val)args);
+        _functionName = name;
+        setImplicitType(resultType);
+    }
+
+    @Override
+    protected String getOperator() {
+        return _functionName;
+    }
+
+}

Propchange: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/DatastoreFunction.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=797257&r1=797256&r2=797257&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
Thu Jul 23 23:01:55 2009
@@ -297,6 +297,17 @@
     public Arguments newArgumentList(Value v1, Value v2) {
         return new Args((Val) v1, (Val) v2);
     }
+    
+    public Arguments newArgumentList(Value... vs) {
+        if (vs == null)
+           return new Args(null);
+        Val[] vals = new Val[vs.length];
+        int i = 0;
+        for (Value v : vs) {
+            vals[i++] = (Val)v;
+        }
+        return new Args(vals);
+    }
 
     public Value newUnboundVariable(String name, Class type) {
         return new Variable(name, type);
@@ -503,4 +514,8 @@
         val2 = getLiteralRawString(val2);
         return new NullIfExpression((Val) val1, (Val) val2);
     }
+    
+    public Value newFunction(String functionName, Class<?> resultType, Value... args)
{
+        return new DatastoreFunction(functionName, resultType, newArgumentList(args));
+    }
 }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/Args.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/Args.java?rev=797257&r1=797256&r2=797257&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/Args.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/Args.java Thu
Jul 23 23:01:55 2009
@@ -32,24 +32,30 @@
     extends Val
     implements Arguments {
 
-    private final List _args = new ArrayList(3);
+    private final List<Value> _args = new ArrayList<Value>(3);
 
     /**
      * Constructor. Supply values being combined.
      */
     public Args(Value val1, Value val2) {
-        if (val1 instanceof Args)
-            _args.addAll(((Args) val1)._args);
-        else
-            _args.add(val1);
-        if (val2 instanceof Args)
-            _args.addAll(((Args) val2)._args);
-        else
-            _args.add(val2);
+        this(new Value[]{val1, val2});
+    }
+    
+    public Args(Value...values) {
+        if (values == null) {
+           return;
+        }
+        for (Value v : values) {
+            if (v instanceof Args) {
+                _args.addAll(((Args)v)._args);
+            } else {
+                _args.add(v);
+            }
+        }
     }
 
     public Value[] getValues() {
-        return (Value[]) _args.toArray(new Value[_args.size()]);
+        return _args.toArray(new Value[_args.size()]);
     }
 
     public Class getType() {

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/ExpressionFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/ExpressionFactory.java?rev=797257&r1=797256&r2=797257&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/ExpressionFactory.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/ExpressionFactory.java
Thu Jul 23 23:01:55 2009
@@ -269,6 +269,12 @@
      * of which may itself be an argument list.
      */
     public Arguments newArgumentList(Value arg1, Value arg2);
+    
+    /**
+     * Return a function argument list consisting of the given values, any
+     * of which may itself be an argument list.
+     */
+    public Arguments newArgumentList(Value... values);
 
     /**
      * Return an unbound variable. This method will only be called once for
@@ -481,4 +487,9 @@
      * a {@link Number}, {@link String}, or {@link Boolean} instance.
      */
     public Literal newTypeLiteral(Object val, int parseType);
+    
+    /**
+     * Return a value representing the given datastore function with the given arguments.
+     */
+    public Value newFunction(String functionName, Class<?> resultType, Value... args);
 }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/InMemoryExpressionFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/InMemoryExpressionFactory.java?rev=797257&r1=797256&r2=797257&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/InMemoryExpressionFactory.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/InMemoryExpressionFactory.java
Thu Jul 23 23:01:55 2009
@@ -525,6 +525,10 @@
     public Arguments newArgumentList(Value val1, Value val2) {
         return new Args(val1, val2);
     }
+    
+    public Arguments newArgumentList(Value... values) {
+        return new Args(values);
+    }
 
     public Value newUnboundVariable(String name, Class type) {
         UnboundVariable var = new UnboundVariable(type);
@@ -788,4 +792,8 @@
     public Value nullIfExpression(Value val1, Value val2) {
         return new NullIf((Val) val1, (Val) val2);
     }
+
+    public Value newFunction(String functionName, Class<?> resultType, Value... args)
{
+        throw new AbstractMethodError();
+    }
 }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/CriteriaTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/CriteriaTest.java?rev=797257&r1=797256&r2=797257&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/CriteriaTest.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/CriteriaTest.java
Thu Jul 23 23:01:55 2009
@@ -328,6 +328,10 @@
         assertFalse(auditor.getSQLs().isEmpty());
         return auditor.getSQLs();
     }
+    
+    void executeAndCompareSQL(CriteriaQuery<?> q, String expectedSQL) {
+        executeAndCompareSQL(em.createQuery(q), expectedSQL);
+    }
 
     String extractSQL(Exception e) {
         Throwable t = e.getCause();

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypesafeCriteria.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypesafeCriteria.java?rev=797257&r1=797256&r2=797257&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypesafeCriteria.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypesafeCriteria.java
Thu Jul 23 23:01:55 2009
@@ -802,4 +802,58 @@
 
         assertEquivalence(q, jpql);
     }
+    
+    /**
+     * 0-arg function works only if there is a other projection items to determine the table
to select from. 
+     */
+    public void testFunctionWithNoArgument() {
+        String jpql = "SELECT c.balanceOwed FROM Customer c";
+        String sql = "SELECT CURRENT_USER(), t0.balanceOwed FROM CR_CUST t0";
+        
+        CriteriaQuery<Tuple> q = cb.createTupleQuery();
+        Root<Customer> c = q.from(Customer.class);
+        q.multiselect(cb.function("CURRENT_USER", String.class, (Expression<?>[])null),
c.get(Customer_.balanceOwed));
+        
+        executeAndCompareSQL(q, sql);
+//        assertEquivalence(q, jpql);
+    }
+
+    public void testFunctionWithOneArgument() {
+        String jpql = "SELECT MAX(c.balanceOwed) FROM Customer c";
+        
+        CriteriaQuery<Tuple> q = cb.createTupleQuery();
+        Root<Customer> c = q.from(Customer.class);
+        q.multiselect(cb.function("MAX", Integer.class, c.get(Customer_.balanceOwed)));
+        
+        assertEquivalence(q, jpql);
+
+    }
+    
+    public void testFunctionWithTwoArgument() {
+        String jpql = "SELECT MOD(c.balanceOwed,10) FROM Customer c";
+        
+        CriteriaQuery<Tuple> q = cb.createTupleQuery();
+        Root<Customer> c = q.from(Customer.class);
+        q.multiselect(cb.function("MOD", Integer.class, c.get(Customer_.balanceOwed), cb.literal(10)));
+        
+        assertEquivalence(q, jpql);
+
+    }
+    
+    public void testFunctionWithFunctionArgumentInOrderBy() {
+        String jpql = "SELECT MOD(c.balanceOwed,10) FROM Customer c WHERE LENGTH(c.name)>3
ORDER BY LENGTH(c.name)";
+        String sql = "SELECT MOD(t0.balanceOwed, ?), LENGTH(t0.name) FROM CR_CUST t0 WHERE
(LENGTH(t0.name) > ?) " +
+                     "ORDER BY LENGTH(t0.name) ASC";
+        
+        CriteriaQuery<Tuple> q = cb.createTupleQuery();
+        Root<Customer> c = q.from(Customer.class);
+        Expression<Integer> nameLength = cb.function("LENGTH", Integer.class, c.get(Customer_.name));
+        q.multiselect(cb.function("MOD", Integer.class, c.get(Customer_.balanceOwed), cb.literal(10)));
+        q.where(cb.greaterThan(nameLength, 3));
+        q.orderBy(cb.asc(nameLength));
+        
+        executeAndCompareSQL(q, sql);
+
+    }
+
 }

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaBuilder.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaBuilder.java?rev=797257&r1=797256&r2=797257&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaBuilder.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaBuilder.java
Thu Jul 23 23:01:55 2009
@@ -246,7 +246,7 @@
 
     public <T> Expression<T> function(String name, Class<T> type,
         Expression<?>... args) {
-        throw new AbstractMethodError();
+        return new Expressions.DatabaseFunction(name, type, args);
     }
 
     public Predicate ge(Expression<? extends Number> x,

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaQueryImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaQueryImpl.java?rev=797257&r1=797256&r2=797257&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaQueryImpl.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaQueryImpl.java
Thu Jul 23 23:01:55 2009
@@ -81,8 +81,7 @@
     private static String ALIAS_BASE = "autoAlias";
     
     // Auto-generated Parameter name 
-    private int autoParameterCount = 0;
-    private static String PARAM_BASE = "autoParam";
+    private static String PARAM_BASE = "*autoParam";
     
     private Map<Selection<?>,Value> _variables = new HashMap<Selection<?>,
Value>();
     private Map<Selection<?>,Value> _values    = new HashMap<Selection<?>,
Value>();
@@ -194,9 +193,13 @@
         if (_paramTypes == null) {
             _paramTypes = new LinkedHashMap<ParameterExpression<?>, Class<?>>();
         }
+        if (_paramTypes.containsKey(p)) {
+            return;
+        }
+        p.setIndex(_paramTypes.size());
         _paramTypes.put(p, p.getJavaType());
         if (p.getName() == null)
-            p.assignAutoName(PARAM_BASE + (++autoParameterCount));
+            p.assignAutoName(PARAM_BASE + p.getIndex());
     }
     
     public Set<ParameterExpression<?>> getParameters() {

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/Expressions.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/Expressions.java?rev=797257&r1=797256&r2=797257&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/Expressions.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/Expressions.java
Thu Jul 23 23:01:55 2009
@@ -47,12 +47,12 @@
      * Handles null expression.
      */
      static Value toValue(ExpressionImpl<?> e, ExpressionFactory factory, 
-        MetamodelImpl model, CriteriaQueryImpl q) {
+        MetamodelImpl model, CriteriaQueryImpl<?> q) {
         return (e == null) ? factory.getNull() : e.toValue(factory, model, q);
     }
      
      static void setImplicitTypes(Value v1, Value v2, Class<?> expected, 
-             CriteriaQueryImpl q) {
+             CriteriaQueryImpl<?> q) {
          JPQLExpressionBuilder.setImplicitTypes(v1, v2, expected, 
              q.getMetamodel(), q.getParameterTypes(), q.toString());
      }
@@ -96,9 +96,27 @@
             e2 = (ExpressionImpl<?>)y;
         }
     }
-
     
     /**
+     * Functional Expression applies a function on a list of input Expressions.
+     * 
+     *
+     * @param <X> the type of the resultant expression
+     */
+    public abstract static class FunctionalExpression<X> extends ExpressionImpl<X>{
+        protected final ExpressionImpl<?>[] args;
+        
+        public FunctionalExpression(Class<X> t, Expression<?>... args) {
+            super(t);
+            int len = args == null ? 0 : args.length;
+            this.args = new ExpressionImpl<?>[len];
+            for (int i = 0; args != null && i < args.length; i++) {
+                this.args[i] = (ExpressionImpl<?>)args[i];
+            }
+        }
+    }
+   
+    /**
      * Binary Logical Expression applies a binary function on a pair of
      * input Expression to generate a Predicate.
      *
@@ -216,6 +234,24 @@
         }
     }
     
+    public static class DatabaseFunction<T> extends FunctionalExpression<T> {
+        private final String functionName;
+        private final Class<T> resultType;
+        public  DatabaseFunction(String name, Class<T> resultType, Expression<?>...
exps) {
+            super(resultType, exps);
+            functionName = name;
+            this.resultType = resultType;
+        }
+        
+        @Override
+        public Value toValue(ExpressionFactory factory, MetamodelImpl model,
+            CriteriaQueryImpl<?> q) {
+            return factory.newFunction(functionName, getJavaType(), 
+                new Expressions.ListArgument(resultType, args).toValue(factory, model, q));
+        }
+    }
+
+    
     public static class Type<X> 
         extends UnaryFunctionalExpression<Class<? extends X>> {
         public Type(PathImpl<?, X> path) {
@@ -1345,5 +1381,31 @@
             return e;
         }
     }
+    
+    /**
+     * An expression that is composed of one or more expressions.
+     *
+     * @param <T>
+     */
+    public static class ListArgument<T> extends ExpressionImpl<T> {
+        private final ExpressionImpl<?>[] _args;
+        public ListArgument(Class<T> cls, ExpressionImpl<?>... args) {
+            super(cls);
+            _args = args;
+        }
+        
+        @Override
+        public org.apache.openjpa.kernel.exps.Arguments toValue(
+          ExpressionFactory factory, MetamodelImpl model, CriteriaQueryImpl<?> q) {
+            org.apache.openjpa.kernel.exps.Value[] kvs = new org.apache.openjpa.kernel.exps.Value[_args.length];
+            int i = 0;
+            for (ExpressionImpl<?> arg : _args) {
+                kvs[i++] = arg.toValue(factory, model, q);
+            }
+            org.apache.openjpa.kernel.exps.Arguments e = factory.newArgumentList(kvs);
+            e.setImplicitType(getJavaType());
+            return e;
+        }
+    }
 
 }

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/ParameterExpressionImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/ParameterExpressionImpl.java?rev=797257&r1=797256&r2=797257&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/ParameterExpressionImpl.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/ParameterExpressionImpl.java
Thu Jul 23 23:01:55 2009
@@ -51,6 +51,7 @@
     implements ParameterExpression<T>, QueryParameter<T> {
     
     private String _autoName = null;
+    private int _index = 0; // index of the parameter as seen by the kernel
 	private final ParameterImpl<T> _delegate;
 	
 	/**
@@ -127,6 +128,14 @@
     public final boolean isPositional() {
         return false;
     }
+    
+    void setIndex(int index) {
+        _index = index;
+    }
+    
+    public int getIndex() {
+        return _index;
+    }
 
     public final boolean isValueAssignable(Object v) {
         return _delegate.isValueAssignable(v);
@@ -155,6 +164,7 @@
             ? factory.newCollectionValuedParameter(paramKey, clzz) 
             : factory.newParameter(paramKey, clzz);
         param.setMetaData(meta);
+        param.setIndex(_index);
         
         return param;
     }   



Mime
View raw message