openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fa...@apache.org
Subject svn commit: r762871 - in /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query: Order.java TestSubquery.java
Date Tue, 07 Apr 2009 17:51:37 GMT
Author: fancy
Date: Tue Apr  7 17:51:36 2009
New Revision: 762871

URL: http://svn.apache.org/viewvc?rev=762871&view=rev
Log:
OPENJPA-1024 JPA2 support scalar expressions in subquery
add test strings

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/Order.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestSubquery.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/Order.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/Order.java?rev=762871&r1=762870&r2=762871&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/Order.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/Order.java
Tue Apr  7 17:51:36 2009
@@ -20,6 +20,7 @@
 
 import javax.persistence.*;
 
+import java.sql.Timestamp;
 import java.util.Collection;
 import java.util.ArrayList;
 
@@ -41,7 +42,9 @@
 	@Version
 	long version;
 	
-	public Order(){}
+    Timestamp orderTs;
+
+    public Order(){}
 	
 	public Order(  double amt, boolean delivered, Customer c){
 		amount=amt;
@@ -84,4 +87,12 @@
 	public void setLineitems(Collection<OrderItem> lineitems) {
 		this.lineitems = lineitems;
 	}
+    
+    public Timestamp getOrderTs() {
+        return orderTs;
+    }
+    
+    public void setOrderTs(Timestamp orderTs) {
+        this.orderTs = orderTs;
+    }
 }

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=762871&r1=762870&r2=762871&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
Tue Apr  7 17:51:36 2009
@@ -88,6 +88,34 @@
     //   + " (select o2 from c.orders o2 where o2 = o",
     };
 
+    static String[]  querys_jpa20 = new String[] {        
+        "select o.oid from Order o where o.delivered =" +
+            " (select " +
+            "   CASE WHEN o2.amount > 10 THEN true" + 
+            "     WHEN o2.amount = 10 THEN false " +
+            "     ELSE false " +
+            "     END " +
+            " from Order o2" +
+            " where o.customer.cid.id = o2.customer.cid.id)",
+ 
+        "select o1.oid from Order o1 where o1.amount > " +
+            " (select o.amount*0.8 from OrderItem i, Order o" +
+            " where i.quantity > 10 and o.amount > 1000 and i.lid = o.oid)",
+            
+        "select o.oid from Order o where o.customer.name =" +
+            " (select substring(o2.customer.name, 3) from Order o2" +
+            " where o.customer.cid.id = o2.customer.cid.id)",
+            
+        "select o.oid from Order o where o.orderTs >" +
+            " (select CURRENT_TIMESTAMP from o.lineitems i)",
+            
+        "select o.oid from Order o where o.amount >" +
+            " (select SQRT(o.amount) from Order o where o.delivered = true)",
+            
+        "select o.oid from Order o where o.customer.name in" +
+            " (select CONCAT(o.customer.name, 'XX') from Order o" +
+            " where o.amount > 10)",            
+    };
 
     static String[] updates = new String[] {
         "update Order o set o.amount = 1000 where o.customer.name = " +
@@ -98,8 +126,15 @@
 
     public void testSubquery() {
         EntityManager em = emf.createEntityManager();
+        for (int i = 0; i < querys_jpa20.length; i++) {
+            String q = querys_jpa20[i];
+            System.err.println(">>> JPQL JPA2 :[ " + i + "]" +q);
+            List rs = em.createQuery(q).getResultList();
+            assertEquals(0, rs.size());
+        }
         for (int i = 0; i < querys.length; i++) {
             String q = querys[i];
+            System.err.println(">>> JPQL: [ " + i + "]"+q);
             List rs = em.createQuery(q).getResultList();
             assertEquals(0, rs.size());
         }



Mime
View raw message