openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r766204 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/
Date Sat, 18 Apr 2009 02:54:36 GMT
Author: faywang
Date: Sat Apr 18 02:54:35 2009
New Revision: 766204

URL: http://svn.apache.org/viewvc?rev=766204&view=rev
Log:
OPENJPA-1024: subquery support of nullif and coalesce for enum literals

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/CoalesceExpression.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/NullIfExpression.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/SubQ.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/Customer.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestSubquery.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/CoalesceExpression.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/CoalesceExpression.java?rev=766204&r1=766203&r2=766204&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/CoalesceExpression.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/CoalesceExpression.java
Sat Apr 18 02:54:35 2009
@@ -28,6 +28,7 @@
 import org.apache.openjpa.jdbc.sql.Select;
 import org.apache.openjpa.kernel.Filters;
 import org.apache.openjpa.kernel.exps.ExpressionVisitor;
+import org.apache.openjpa.kernel.exps.Value;
 import org.apache.openjpa.meta.ClassMetaData;
 
 /**
@@ -41,6 +42,8 @@
     private final Val[] _vals;
     private ClassMetaData _meta = null;
     private Class _cast = null;
+    private Value other = null;
+    private ExpState otherState = null;
 
     /**
      * Constructor.
@@ -171,5 +174,21 @@
     public void setMetaData(ClassMetaData meta) {
         _meta = meta;
     }
+    
+    public void setOtherPath(Value other) {
+        this.other = other;
+    }
+    
+    public Value getOtherPath() {
+        return other;
+    }
+    
+    public void setOtherState(ExpState otherState) {
+        this.otherState = otherState;
+    }
+    
+    public ExpState getOtherState() {
+        return otherState;
+    }
 }
 

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/NullIfExpression.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/NullIfExpression.java?rev=766204&r1=766203&r2=766204&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/NullIfExpression.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/NullIfExpression.java
Sat Apr 18 02:54:35 2009
@@ -27,6 +27,7 @@
 import org.apache.openjpa.jdbc.sql.Select;
 import org.apache.openjpa.kernel.Filters;
 import org.apache.openjpa.kernel.exps.ExpressionVisitor;
+import org.apache.openjpa.kernel.exps.Value;
 import org.apache.openjpa.meta.ClassMetaData;
 
 /**
@@ -41,6 +42,8 @@
     private final Val _val2;
     private ClassMetaData _meta = null;
     private Class _cast = null;
+    private Value other = null;
+    private ExpState otherState = null;
 
     /**
      * Constructor.
@@ -155,5 +158,22 @@
     public void setMetaData(ClassMetaData meta) {
         _meta = meta;
     }
+    
+    public void setOtherPath(Value other) {
+        this.other = other;
+    }
+    
+    public Value getOtherPath() {
+        return other;
+    }
+    
+    public void setOtherState(ExpState otherState) {
+        this.otherState = otherState;
+    }
+    
+    public ExpState getOtherState() {
+        return otherState;
+    }
+    
 }
 

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/SubQ.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/SubQ.java?rev=766204&r1=766203&r2=766204&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/SubQ.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/SubQ.java
Sat Apr 18 02:54:35 2009
@@ -158,6 +158,12 @@
             } else if (projs[i] instanceof SimpleCaseExpression) {
                 ((SimpleCaseExpression)projs[i]).setOtherPath(other);
                 ((SimpleCaseExpression)projs[i]).setOtherState(otherState);
+            } else if (projs[i] instanceof NullIfExpression) {
+                ((NullIfExpression)projs[i]).setOtherPath(other);
+                ((NullIfExpression)projs[i]).setOtherState(otherState);
+            } else if (projs[i] instanceof CoalesceExpression) {
+                ((CoalesceExpression)projs[i]).setOtherPath(other);
+                ((CoalesceExpression)projs[i]).setOtherState(otherState);
             }
         }
     }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/Customer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/Customer.java?rev=766204&r1=766203&r2=766204&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/Customer.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/Customer.java
Sat Apr 18 02:54:35 2009
@@ -67,7 +67,7 @@
 	@Column(length=30)
     @Basic
 	 String name;
-	@Enumerated
+	@Enumerated(EnumType.STRING)
     @Basic
 	 CreditRating creditRating;
 	@Version

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestSubquery.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestSubquery.java?rev=766204&r1=766203&r2=766204&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestSubquery.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestSubquery.java
Sat Apr 18 02:54:35 2009
@@ -114,7 +114,8 @@
             
         "select o.oid from Order o where o.customer.name in" +
             " (select CONCAT(o.customer.name, 'XX') from Order o" +
-            " where o.amount > 10)",            
+            " where o.amount > 10)",  
+            
         "select c from Customer c where c.creditRating =" +
             " (select " +
             "   CASE WHEN o2.amount > 10 THEN " + 
@@ -126,6 +127,16 @@
             "     END " +
             " from Order o2" +
             " where c.cid.id = o2.customer.cid.id)",
+
+        "select c from Customer c " + 
+            "where c.creditRating = (select COALESCE (c1.creditRating, " + 
+            "org.apache.openjpa.persistence.query.Customer$CreditRating.POOR) " +
+            "from Customer c1 where c1.name = 'Famzy') order by c.name DESC", 
+            
+        "select c from Customer c " + 
+            "where c.creditRating = (select NULLIF (c1.creditRating, " + 
+            "org.apache.openjpa.persistence.query.Customer$CreditRating.POOR) " +
+            "from Customer c1 where c1.name = 'Famzy') order by c.name DESC",           

     };
 
     static String[] updates = new String[] {



Mime
View raw message