openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r775009 - in /openjpa/trunk: openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/
Date Fri, 15 May 2009 05:27:38 GMT
Author: faywang
Date: Fri May 15 05:27:38 2009
New Revision: 775009

URL: http://svn.apache.org/viewvc?rev=775009&view=rev
Log:
OPENJPA-1013: MEMBER OF support for criteria query

Modified:
    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/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/PathImpl.java

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=775009&r1=775008&r2=775009&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
Fri May 15 05:27:38 2009
@@ -403,7 +403,6 @@
         assertEquivalence(q, jpql);
     }    
     
-    @AllowFailure
     public void testLiterals() {
         String jpql = "SELECT p FROM Person p where 'Joe' MEMBER OF p.nickNames";
         CriteriaQuery q = cb.create();

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=775009&r1=775008&r2=775009&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
Fri May 15 05:27:38 2009
@@ -177,11 +177,11 @@
 	    	   exps.accessPath[i++] = ((Types.Managed<?>)r.getModel()).meta;
 	    }
 	//    exps.alias = null;      // String   
-	    exps.ascending = new boolean[]{false};
-	    exps.distinct = _distinct == null ? QueryExpressions.DISTINCT_AUTO :
-	    	_distinct ? QueryExpressions.DISTINCT_TRUE 
-	    			  : QueryExpressions.DISTINCT_FALSE;
-	//    exps.fetchInnerPaths = null; // String[]
+        exps.distinct = _distinct == null ? QueryExpressions.DISTINCT_FALSE :
+            _distinct ?
+            QueryExpressions.DISTINCT_TRUE | QueryExpressions.DISTINCT_AUTO : 
+            QueryExpressions.DISTINCT_FALSE;
+    //    exps.fetchInnerPaths = null; // String[]
 	//    exps.fetchPaths = null;      // String[]
 	    exps.filter = _where == null ? factory.emptyExpression() 
 	    		: _where.toKernelExpression(factory, _model);

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=775009&r1=775008&r2=775009&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
Fri May 15 05:27:38 2009
@@ -39,8 +39,6 @@
 	static Value toValue(ExpressionImpl<?> e, ExpressionFactory factory, 
 		MetamodelImpl model) {
 		Value v = e.toValue(factory, model);
-		v.setImplicitType(e.getJavaType());
-		v.setAlias(e.getAlias());
 		return v;
 	}
 	
@@ -618,8 +616,9 @@
         @Override
         public org.apache.openjpa.kernel.exps.Expression toKernelExpression(
         	ExpressionFactory factory, MetamodelImpl model) {
-            return factory.contains(factory.getThis(),
-            	Expressions.toValue(collection, factory, model));
+            return factory.contains(
+                Expressions.toValue(collection, factory, model), 
+                Expressions.toValue(element, factory, model));
         }
     }
     

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/PathImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/PathImpl.java?rev=775009&r1=775008&r2=775009&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/PathImpl.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/PathImpl.java
Fri May 15 05:27:38 2009
@@ -28,6 +28,7 @@
 
 import org.apache.openjpa.kernel.exps.ExpressionFactory;
 import org.apache.openjpa.kernel.exps.Value;
+import org.apache.openjpa.meta.JavaTypes;
 import org.apache.openjpa.persistence.meta.Members;
 import org.apache.openjpa.persistence.meta.MetamodelImpl;
 
@@ -75,6 +76,13 @@
             var = factory.newPath();//getJavaType());
             var.setMetaData(model.repos.getMetaData(getJavaType(), null, true));
         }
+        if (member != null) {
+            int typeCode = member.fmd.getDeclaredTypeCode();
+            if (typeCode != JavaTypes.COLLECTION && typeCode != JavaTypes.MAP)
+                var.setImplicitType(getJavaType());
+        }
+        var.setAlias(getAlias());
+        
         return var;
     }
 



Mime
View raw message