openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r918621 - in /openjpa/branches/1.3.x: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/subquery/TestJPQLSubquery.java
Date Wed, 03 Mar 2010 18:45:37 GMT
Author: faywang
Date: Wed Mar  3 18:45:37 2010
New Revision: 918621

URL: http://svn.apache.org/viewvc?rev=918621&view=rev
Log:
OPENJPA-1547: fix SQL syntax error for JPQL involved Not IN (subquery with Member of)

Modified:
    openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java
    openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/subquery/TestJPQLSubquery.java

Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java?rev=918621&r1=918620&r2=918621&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java
(original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java
Wed Mar  3 18:45:37 2010
@@ -166,7 +166,8 @@
     }
 
     public Expression not(Expression exp) {
-        if (!(exp instanceof IsNotEmptyExpression) &&
+        if (!(exp instanceof IsNotEmptyExpression) && 
+            !(exp instanceof InSubQExpression) &&
             HasContainsExpressionVisitor.hasContains(exp))
             return new NotContainsExpression((Exp) exp);
         return new NotExpression((Exp) exp);

Modified: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/subquery/TestJPQLSubquery.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/subquery/TestJPQLSubquery.java?rev=918621&r1=918620&r2=918621&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/subquery/TestJPQLSubquery.java
(original)
+++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/subquery/TestJPQLSubquery.java
Wed Mar  3 18:45:37 2010
@@ -1171,6 +1171,20 @@
         executeAndCompareSQL(jpql, expectedSQL);
     }    
 
+    public void testNotInSubqueryWithMemberOf() {
+        String jpql = "SELECT c.balanceOwed FROM Customer c WHERE c.name not in " 
+            + "(select cu.name FROM CompUser cu where ?1 MEMBER OF cu.nicknames)";
+        String expectedSQL = "SELECT t0.balanceOwed FROM CR_CUST t0 WHERE (NOT (t0.name IN
" + 
+            "(SELECT t1.name FROM CR_COMPUSER t1 INNER JOIN CR_COMPUSER_nicknames t2 " +

+            "ON t1.userid = t2.COMPUSER_USERID WHERE (t2.element = ?))))";
+
+        EntityManager em = emf.createEntityManager();
+        Query jQ = em.createQuery(jpql);
+        jQ.setParameter(1, "nickName1");    
+        
+        executeQueryAndCompareSQL(jQ, jpql, expectedSQL);
+    }
+
     void executeQueryAndCompareSQL(Query q, String jpql, String expectedSQL) {
         JDBCConfiguration conf = (JDBCConfiguration) emf.getConfiguration();
         DBDictionary dict = conf.getDBDictionaryInstance();



Mime
View raw message