cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r699283 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLDeleteTest.java
Date Fri, 26 Sep 2008 11:36:16 GMT
Author: aadamchik
Date: Fri Sep 26 04:36:15 2008
New Revision: 699283

URL: http://svn.apache.org/viewvc?rev=699283&view=rev
Log:
patch testing EJBQL delete with an IN

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLDeleteTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLDeleteTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLDeleteTest.java?rev=699283&r1=699282&r2=699283&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLDeleteTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLDeleteTest.java
Fri Sep 26 04:36:15 2008
@@ -18,6 +18,9 @@
  ****************************************************************/
 package org.apache.cayenne.access;
 
+import java.util.List;
+
+import org.apache.art.MeaningfulPKTest1;
 import org.apache.art.Painting;
 import org.apache.cayenne.DataObjectUtils;
 import org.apache.cayenne.QueryResponse;
@@ -26,9 +29,12 @@
 
 public class DataContextEJBQLDeleteTest extends CayenneCase {
     
+    protected DataContext context;
+    
     @Override
     protected void setUp() throws Exception {
         deleteTestData();
+        context = getDomain().createDataContext();
     }
     
     public void testDeleteNoIdVar() throws Exception {
@@ -77,4 +83,35 @@
         assertNull(DataObjectUtils
                 .objectForPK(createDataContext(), Painting.class, 33002));
     }
+    
+    public void testDeleteIdVar() throws Exception {
+        insertValue();
+        
+        EJBQLQuery q = new EJBQLQuery("select m.pkAttribute from MeaningfulPKTest1 m");
+    
+        List<Integer> id = createDataContext().performQuery(q);
+       
+        String ejbql = "delete from MeaningfulPKTest1 m WHERE m.pkAttribute in (:id)";
+         
+        EJBQLQuery query = new EJBQLQuery(ejbql);
+        query.setParameter("id", id);
+        QueryResponse result = createDataContext().performGenericQuery(query);
+    
+        int[] count = result.firstUpdateCount();
+        assertNotNull(count);
+        assertEquals(1, count.length);
+        assertEquals(420, count[0]);
+
+    }
+    
+    public void insertValue(){
+        MeaningfulPKTest1 obj ;
+        
+        for(int i=0;i<420;i++){
+            obj = (MeaningfulPKTest1) context.newObject("MeaningfulPKTest1");
+            obj.setPkAttribute(new Integer(i));
+            obj.setDescr("a" + i);
+            context.commitChanges();
+        }
+    }
 }



Mime
View raw message