cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r606485 - /cayenne/main/trunk/itests/jpa-chapter3/src/test/java/org/apache/cayenne/jpa/itest/ch3/_3_1_1_EntityManagerTest.java
Date Sat, 22 Dec 2007 20:24:24 GMT
Author: aadamchik
Date: Sat Dec 22 12:24:22 2007
New Revision: 606485

URL: http://svn.apache.org/viewvc?rev=606485&view=rev
Log:
JPA: adding native query integration test

Modified:
    cayenne/main/trunk/itests/jpa-chapter3/src/test/java/org/apache/cayenne/jpa/itest/ch3/_3_1_1_EntityManagerTest.java

Modified: cayenne/main/trunk/itests/jpa-chapter3/src/test/java/org/apache/cayenne/jpa/itest/ch3/_3_1_1_EntityManagerTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/itests/jpa-chapter3/src/test/java/org/apache/cayenne/jpa/itest/ch3/_3_1_1_EntityManagerTest.java?rev=606485&r1=606484&r2=606485&view=diff
==============================================================================
--- cayenne/main/trunk/itests/jpa-chapter3/src/test/java/org/apache/cayenne/jpa/itest/ch3/_3_1_1_EntityManagerTest.java
(original)
+++ cayenne/main/trunk/itests/jpa-chapter3/src/test/java/org/apache/cayenne/jpa/itest/ch3/_3_1_1_EntityManagerTest.java
Sat Dec 22 12:24:22 2007
@@ -233,10 +233,27 @@
 
         Query query = getEntityManager().createQuery("select x from SimpleEntity x");
         assertNotNull(query);
-        List result = query.getResultList();
+        List<?> result = query.getResultList();
         assertNotNull(result);
         assertEquals(1, result.size());
         assertTrue(result.get(0) instanceof SimpleEntity);
         assertEquals("XXX", ((SimpleEntity) result.get(0)).getProperty1());
+    }
+
+    public void testCreateNativeQuery() throws Exception {
+        getDbHelper().deleteAll("SimpleEntity");
+
+        getDbHelper().insert("SimpleEntity", new String[] {
+                "id", "property1"
+        }, new Object[] {
+                15, "XXX"
+        });
+
+        Query query = getEntityManager().createNativeQuery(
+                "DELETE FROM SimpleEntity WHERE id = 15");
+        assertNotNull(query);
+        assertEquals(1, query.executeUpdate());
+
+        assertEquals(0, getDbHelper().getRowCount("SimpleEntity"));
     }
 }



Mime
View raw message