openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r763149 - in /openjpa/trunk: openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestCriteria.java openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BinaryExpressionPredicate.java
Date Wed, 08 Apr 2009 09:06:12 GMT
Author: ppoddar
Date: Wed Apr  8 09:06:11 2009
New Revision: 763149

URL: http://svn.apache.org/viewvc?rev=763149&view=rev
Log:
OPENJPA-1024: Scalar expression in SubQuery requires subquery expression be enclosed in parentheses

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestCriteria.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BinaryExpressionPredicate.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestCriteria.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestCriteria.java?rev=763149&r1=763148&r2=763149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestCriteria.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestCriteria.java
Wed Apr  8 09:06:11 2009
@@ -31,7 +31,6 @@
 import org.apache.openjpa.persistence.query.QueryBuilderImpl;
 import org.apache.openjpa.persistence.query.QueryDefinition;
 import org.apache.openjpa.persistence.query.SelectItem;
-import org.apache.openjpa.persistence.test.AllowFailure;
 import org.apache.openjpa.persistence.test.SingleEMFTestCase;
 
 
@@ -270,7 +269,6 @@
 		compare(jpql, o);
 	}
 
-	@AllowFailure
 	public void testNonCorrelatedSubQuery() {
 		QueryDefinition q1 = qb.createQueryDefinition();
 		DomainObject goodCustomer = q1.addRoot(Customer.class);
@@ -416,7 +414,6 @@
 		compare(jpql, q1);
 	}
 	
-	@AllowFailure
 	public void testCreateSubquery() {
 		DomainObject customer = qb.createQueryDefinition(Customer.class);
 		DomainObject order = qb.createSubqueryDefinition(customer.get("orders"));

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BinaryExpressionPredicate.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BinaryExpressionPredicate.java?rev=763149&r1=763148&r2=763149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BinaryExpressionPredicate.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/query/BinaryExpressionPredicate.java
Wed Apr  8 09:06:11 2009
@@ -67,8 +67,15 @@
 	}
 
 	public String asExpression(AliasContext ctx) {
-		return ((Visitable)_e1).asExpression(ctx) 
+		return asExpression((Visitable)_e1, ctx)  
 		     + SPACE + _op + SPACE
-		     + ((Visitable)_e2).asExpression(ctx);
+		     + asExpression((Visitable)_e2, ctx);
+	}
+	
+	String asExpression(Visitable v, AliasContext ctx) {
+		String result = v.asExpression(ctx);
+		if (v instanceof QueryDefinitionImpl)
+		    return "(" + result + ")";
+		return result;
 	}
 }



Mime
View raw message