db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r528941 - /db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java
Date Sun, 15 Apr 2007 08:30:57 GMT
Author: tfischer
Date: Sun Apr 15 01:30:56 2007
New Revision: 528941

URL: http://svn.apache.org/viewvc?view=rev&rev=528941
Log:
- Added testcase for problem with doDelete() and joins (failing in the moment !)
- fixed interface testing (database was complaining about duplicate data sets)

Modified:
    db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java

Modified: db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java
URL: http://svn.apache.org/viewvc/db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java?view=diff&rev=528941&r1=528940&r2=528941
==============================================================================
--- db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java (original)
+++ db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java Sun Apr 15
01:30:56 2007
@@ -67,9 +67,9 @@
 import org.apache.torque.test.DateTest;
 import org.apache.torque.test.DateTestPeer;
 import org.apache.torque.test.IfcTable;
-import org.apache.torque.test.IfcTablePeer;
 import org.apache.torque.test.IfcTable2;
 import org.apache.torque.test.IfcTable2Peer;
+import org.apache.torque.test.IfcTablePeer;
 import org.apache.torque.test.IntegerPk;
 import org.apache.torque.test.IntegerPkPeer;
 import org.apache.torque.test.LargePk;
@@ -617,6 +617,34 @@
         authorResult = AuthorPeer.doSelect(new Criteria());
         assertTrue("deleted not enough records",
             authorResult.size() == 0);
+
+        // re-create data and check that a delete with join does not delete
+        // data in the joined table as well.
+        author = new Author();
+        author.setName("Name");
+        author.save();
+
+        book = new Book();
+        book.setTitle("title");
+        book.setAuthor(author);
+        book.setIsbn("ISBN");
+        book.save();
+
+        criteria.clear();
+        criteria.add(AuthorPeer.AUTHOR_ID, author.getAuthorId());
+        criteria.addJoin(AuthorPeer.AUTHOR_ID, BookPeer.AUTHOR_ID);
+        // The following where clause is nit necessary from a sql pointof view.
+        // However, it adds a second table to the where clauses of the
+        // criteria, so that it cannot be determined from the criteria alone
+        // which table should be deleted from.
+        criteria.add(BookPeer.AUTHOR_ID, book.getAuthorId());
+        AuthorPeer.doDelete(criteria);
+        authorResult = AuthorPeer.doSelect(new Criteria());
+        bookResult = BookPeer.doSelect(new Criteria());
+        assertTrue("deleted not enough records",
+                authorResult.size() == 0);
+        assertTrue("delete also deleted objects in joined table",
+                bookResult.size() == 1);
     }
 
     /**
@@ -1696,6 +1724,10 @@
      */
     public void testInterface() throws Exception
     {
+        Criteria criteria = new Criteria();
+        criteria.add(IfcTablePeer.ID, -1, Criteria.NOT_EQUAL);
+        IfcTablePeer.doDelete(criteria);
+        
         IfcTable ifc = new IfcTable();
         
         assertTrue("IfcTable should be an instance of TestInterface", ifc instanceof TestInterface);
@@ -1715,10 +1747,6 @@
         IfcTable2 ifc2 = new IfcTable2();
 
         assertTrue("IfcTable2 should be an instance of LocalTestInterface", ifc2 instanceof
LocalTestInterface);
-
-        ifc2.setID(1);
-        ifc2.setName("John Doe");
-        ifc2.save();
 
         List results2 = IfcTable2Peer.doSelect(new Criteria());
         



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message