Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencedObject.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencedObject.vm?rev=1331179&r1=1331178&r2=1331179&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencedObject.vm (original) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencedObject.vm Fri Apr 27 02:00:16 2012 @@ -57,9 +57,8 @@ Connection connection = null; try { - connection = Transaction.beginOptional( - ${localPeerClassName}.DATABASE_NAME, - true); + connection = Transaction.begin( + ${localPeerClassName}.DATABASE_NAME); List<${fieldType}> result = ${filler}(toFill, connection); Transaction.commit(connection); connection = null;
Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencingObjects.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencingObjects.vm?rev=1331179&r1=1331178&r2=1331179&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencingObjects.vm (original) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencingObjects.vm Fri Apr 27 02:00:16 2012 @@ -57,9 +57,8 @@ Connection connection = null; try { - connection = Transaction.beginOptional( - ${localPeerClassName}.DATABASE_NAME, - true); + connection = Transaction.begin( + ${localPeerClassName}.DATABASE_NAME); List<${fieldContainedType}> result = ${filler}(toFill, connection); Transaction.commit(connection); connection = null; Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java?rev=1331179&r1=1331178&r2=1331179&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java (original) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java Fri Apr 27 02:00:16 2012 @@ -31,7 +31,6 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.torque.adapter.DB; -import org.apache.torque.adapter.DBHsqldb; import org.apache.torque.adapter.DBMM; import org.apache.torque.adapter.DBMSSQL; import org.apache.torque.criteria.Criteria; @@ -39,20 +38,14 @@ import org.apache.torque.criteria.Criter import org.apache.torque.om.mapper.CompositeMapper; import org.apache.torque.om.mapper.IntegerMapper; import org.apache.torque.om.mapper.RecordMapper; -import org.apache.torque.test.A; -import org.apache.torque.test.APeer; import org.apache.torque.test.Author; import org.apache.torque.test.AuthorPeer; import org.apache.torque.test.AuthorRecordMapper; -import org.apache.torque.test.B; -import org.apache.torque.test.BPeer; import org.apache.torque.test.BlobTest; import org.apache.torque.test.BlobTestPeer; import org.apache.torque.test.Book; import org.apache.torque.test.BookPeer; import org.apache.torque.test.BookRecordMapper; -import org.apache.torque.test.C; -import org.apache.torque.test.CPeer; import org.apache.torque.test.ClobTest; import org.apache.torque.test.ClobTestPeer; import org.apache.torque.test.IfcTable; @@ -81,8 +74,6 @@ import org.apache.torque.test.Nopk; import org.apache.torque.test.NopkPeer; import org.apache.torque.test.NullValueTable; import org.apache.torque.test.NullValueTablePeer; -import org.apache.torque.test.RAb; -import org.apache.torque.test.RAbPeer; import org.apache.torque.util.BasePeer; import org.apache.torque.util.CountHelper; import org.apache.torque.util.Transaction; @@ -205,7 +196,7 @@ public class DataTest extends BaseDataba // check that Offset also works without limit crit = new Criteria(); crit.setOffset(5); - books = MyBookPeer.doSelect(crit); + books = BookPeer.doSelect(crit); assertTrue("List should have 95 books, not " + books.size(), books.size() == 95); @@ -215,7 +206,7 @@ public class DataTest extends BaseDataba crit = new Criteria(); crit.setLimit(10); crit.setOffset(5); - books = MyBookPeer.doSelectJoinAuthor(crit); + books = BookPeer.doSelectJoinAuthor(crit); assertTrue("List should have 10 books, not " + books.size(), books.size() == 10); } @@ -494,212 +485,6 @@ public class DataTest extends BaseDataba } /** - * test joins - * @throws Exception if the test fails - */ - public void testJoins() throws Exception - { - cleanBookstore(); - - // insert test data - Author author = new Author(); - author.setName("Author with one book"); - author.save(); - Book book = new Book(); - book.setAuthor(author); - book.setTitle("Book 1"); - book.setIsbn("unknown"); - book.save(); - - author = new Author(); - author.setName("Author without book"); - author.save(); - - author = new Author(); - author.setName("Author with three books"); - author.save(); - for (int bookNr = 2; bookNr <=4; bookNr++) - { - book = new Book(); - book.setAuthor(author); - book.setTitle("Book " + bookNr); - book.setIsbn("unknown"); - book.save(); - } - - // test left join - Criteria criteria = new Criteria(); - criteria.addJoin(AuthorPeer.AUTHOR_ID, BookPeer.AUTHOR_ID, - Criteria.LEFT_JOIN); - List<Author> authorList = AuthorPeer.doSelect(criteria); - // Here we get 5 authors: - // the author with one book, the author without books, - // and three times the author with three books - if (authorList.size() != 5) - { - fail("author left join book : " - + "incorrect numbers of authors found : " - + authorList.size() - + ", should be 5"); - } - - // test inner join - criteria = new Criteria(); - criteria.addJoin( - AuthorPeer.AUTHOR_ID, BookPeer.AUTHOR_ID, - Criteria.INNER_JOIN); - authorList = AuthorPeer.doSelect(criteria); - // Here we get 4 authors: - // the author with one book, - // and three times the author with three books - if (authorList.size() != 4) - { - fail("author left join book : " - + "incorrect numbers of authors found : " - + authorList.size() - + ", should be 4"); - } - - if (Torque.getDB(Torque.getDefaultDB()) instanceof DBHsqldb) - { - log.error("testJoins(): Right joins are not supported by HSQLDB"); - // failing is "expected", so exit without error - return; - } - - // test right join - criteria = new Criteria(); - criteria.addJoin( - BookPeer.AUTHOR_ID, AuthorPeer.AUTHOR_ID, - Criteria.RIGHT_JOIN); - authorList = AuthorPeer.doSelect(criteria); - // Here we get 4 authors: - // the author with one book, the author without books, - // and three times the author with three books - if (authorList.size() != 5) - { - fail("book right join author " - + "incorrect numbers of authors found : " - + authorList.size() - + ", should be 5"); - } - - // test double join with aliases - criteria = new Criteria(); - criteria.addAlias("b", BookPeer.TABLE_NAME); - criteria.addJoin( - BookPeer.AUTHOR_ID, AuthorPeer.AUTHOR_ID, - Criteria.RIGHT_JOIN); - criteria.addJoin( - AuthorPeer.AUTHOR_ID, - new ColumnImpl("b." + BookPeer.AUTHOR_ID.getColumnName()), - Criteria.LEFT_JOIN); - authorList = AuthorPeer.doSelect(criteria); - // Here we get 11 authors: - // the author with one book, the author without books, - // and nine times the author with three books - if (authorList.size() != 11) - { - fail("book right join author left join book b: " - + "incorrect numbers of authors found : " - + authorList.size() - + ", should be 11"); - } - - // test double join with aliases and "reversed" second join - criteria = new Criteria(); - criteria.addAlias("b", BookPeer.TABLE_NAME); - criteria.addJoin(BookPeer.AUTHOR_ID, AuthorPeer.AUTHOR_ID, - Criteria.RIGHT_JOIN); - criteria.addJoin( - new ColumnImpl("b." + BookPeer.AUTHOR_ID.getColumnName()), - AuthorPeer.AUTHOR_ID, - Criteria.RIGHT_JOIN); - authorList = AuthorPeer.doSelect(criteria); - // Here we get 11 authors: - // the author with one book, the author without books, - // and nine times the author with three books - if (authorList.size() != 11) - { - fail("book right join author left join book b (reversed): " - + "incorrect numbers of authors found : " - + authorList.size() - + ", should be 11"); - } - } - - - /** - * Test joins using the XPeer.DoSelectJoinYYY methods - * @throws Exception if the Test fails - */ - public void testDoSelectJoinY() throws Exception - { - // using the test data from testJoins() - Criteria criteria = new Criteria(); - criteria.addAscendingOrderByColumn(BookPeer.TITLE); - List<Book> books = MyBookPeer.doSelectJoinAuthor(criteria); - assertTrue("books should contain 4 books but contains " - + books.size(), books.size() == 4); - Book bookTwo = books.get(1); - Book bookThree = books.get(2); - assertTrue ("the authors of BookTwo and BookThree" - + " should point to the same instance", - bookTwo.getAuthor() == bookThree.getAuthor()); - } - - /** - * Test joins using the XPeer.DoSelectJoinAllExceptYYY methods - * @throws Exception if the Test fails - */ - public void testDoSelectJoinAllExceptY() throws Exception - { - cleanABC(); - - // setup test data - A a = new A(); - a.setName("test a"); - a.save(); - - B b = new B(); - b.setName("test b"); - b.save(); - - RAb rab = new RAb(); - rab.setName("test rab"); - rab.setA(a); - rab.setB(b); - rab.save(); - - C c = new C(); - c.setName("test c"); - c.setA(a); - c.setB(b); - c.setRAb(rab); - c.save(); - - Criteria criteria = new Criteria(); - criteria.add(APeer.A_ID, a.getAId()); - List<C> list = MyCPeer.doSelectJoinAllExceptA(criteria); - assertTrue("list should contain 1 entry but contains " - + list.size(), list.size() == 1); - - C c1 = list.get(0); - B b1 = c1.getB(); - RAb rab1 = c1.getRAb(); - - assertTrue("The name of c1 should be 'test c' but is " + c1.getName(), - c1.getName().equals("test c")); - assertTrue("The name of b1 should be 'test b' but is " + b1.getName(), - b1.getName().equals("test b")); - assertTrue("The name of rab1 should be 'test rab' but is " + rab1.getName(), - rab1.getName().equals("test rab")); - assertTrue ("The c's of b1 and rab1" - + " should point to the same instance", - b1.getCs().get(0) == rab1.getCs().get(0)); - } - - /** * test the order by, especially in joins and with aliases * @throws Exception if the test fails */ @@ -1232,11 +1017,11 @@ public class DataTest extends BaseDataba */ public void testSingleQuotes() throws Exception { - cleanABC(); + cleanBookstore(); - A a = new A(); - a.setName("has Single ' Quote"); - a.save(); + Author author = new Author(); + author.setName("has Single ' Quote"); + author.save(); } @@ -1744,34 +1529,6 @@ public class DataTest extends BaseDataba author.getName()); } - /** - * Deletes all As, Bs, Cs and RAs - * @throws Exception if the cleanup fails - */ - protected void cleanABC() throws Exception - { - // clean C table - Criteria criteria = new Criteria(); - criteria.add(CPeer.C_ID, (Long) null, Criteria.NOT_EQUAL); - CPeer.doDelete(criteria); - - // clean R_AB table - criteria = new Criteria(); - criteria.add(RAbPeer.A_ID, (Long) null, Criteria.NOT_EQUAL); - criteria.add(RAbPeer.B_ID, (Long) null, Criteria.NOT_EQUAL); - RAbPeer.doDelete(criteria); - - // clean A table - criteria = new Criteria(); - criteria.add(APeer.A_ID, (Long) null, Criteria.NOT_EQUAL); - APeer.doDelete(criteria); - - // clean B table - criteria = new Criteria(); - criteria.add(BPeer.B_ID, (Long) null, Criteria.NOT_EQUAL); - BPeer.doDelete(criteria); - } - /** * Strips the schema and table name from a fully qualified colum name @@ -1793,31 +1550,6 @@ public class DataTest extends BaseDataba return result; } - - /** - * Subclass of BookPeer to make the doSelectJoinAuthors() visible - */ - static class MyBookPeer extends BookPeer - { - public static List<Book> doSelectJoinAuthor(Criteria criteria) - throws TorqueException - { - return BookPeer.doSelectJoinAuthor(criteria); - } - } - - /** - * Subclass of CPeer to make the doSelectJoinAllExceptA() visible - */ - static class MyCPeer extends CPeer - { - public static List<C> doSelectJoinAllExceptA(Criteria criteria) - throws TorqueException - { - return CPeer.doSelectJoinAllExceptA(criteria); - } - } - static class DoNothingMapper implements RecordMapper<Object> { Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/JoinTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/JoinTest.java?rev=1331179&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/JoinTest.java (added) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/JoinTest.java Fri Apr 27 02:00:16 2012 @@ -0,0 +1,441 @@ +package org.apache.torque.generated.peer; + +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.torque.BaseDatabaseTestCase; +import org.apache.torque.ColumnImpl; +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.adapter.DBHsqldb; +import org.apache.torque.criteria.Criteria; +import org.apache.torque.test.A; +import org.apache.torque.test.APeer; +import org.apache.torque.test.Author; +import org.apache.torque.test.AuthorPeer; +import org.apache.torque.test.B; +import org.apache.torque.test.BPeer; +import org.apache.torque.test.Book; +import org.apache.torque.test.BookPeer; +import org.apache.torque.test.C; +import org.apache.torque.test.CPeer; +import org.apache.torque.test.RAb; +import org.apache.torque.test.RAbPeer; + +/** + * Tests joins. + * + * @version $Id: $ + */ +public class JoinTest extends BaseDatabaseTestCase +{ + private static Log log = LogFactory.getLog(JoinTest.class); + + /** + * Test left joins. + * + * @throws Exception if the test fails + */ + public void testLeftJoins() throws Exception + { + cleanBookstore(); + insertTestData(); + Criteria criteria = new Criteria(); + criteria.addJoin( + AuthorPeer.AUTHOR_ID, + BookPeer.AUTHOR_ID, + Criteria.LEFT_JOIN); + + List<Author> authorList = AuthorPeer.doSelect(criteria); + + // Here we get 5 authors: + // the author with one book, the author without books, + // and three times the author with three books + if (authorList.size() != 5) + { + fail("author left join book : " + + "incorrect numbers of authors found : " + + authorList.size() + + ", should be 5"); + } + } + + /** + * Test inner joins. + * + * @throws Exception if the test fails + */ + public void testInnerJoins() throws Exception + { + cleanBookstore(); + insertTestData(); + Criteria criteria = new Criteria(); + criteria.addJoin( + AuthorPeer.AUTHOR_ID, + BookPeer.AUTHOR_ID, + Criteria.INNER_JOIN); + + List<Author> authorList = AuthorPeer.doSelect(criteria); + + // Here we get 4 authors: + // the author with one book, + // and three times the author with three books + if (authorList.size() != 4) + { + fail("author left join book : " + + "incorrect numbers of authors found : " + + authorList.size() + + ", should be 4"); + } + } + + /** + * Test an implicit inner join. + * + * @throws Exception if the test fails + */ + public void testImplicitInnerJoins() throws Exception + { + cleanBookstore(); + insertTestData(); + Criteria criteria = new Criteria(); + criteria.addJoin( + AuthorPeer.AUTHOR_ID, + BookPeer.AUTHOR_ID); + + List<Author> authorList = AuthorPeer.doSelect(criteria); + + // Here we get 4 authors: + // the author with one book, + // and three times the author with three books + if (authorList.size() != 4) + { + fail("author left join book : " + + "incorrect numbers of authors found : " + + authorList.size() + + ", should be 4"); + } + } + + /** + * Test right joins. + * + * @throws Exception if the test fails + */ + public void testRightJoins() throws Exception + { + if (!supportsRightJoins()) + { + return; + } + + cleanBookstore(); + insertTestData(); + Criteria criteria = new Criteria(); + criteria.addJoin( + BookPeer.AUTHOR_ID, + AuthorPeer.AUTHOR_ID, + Criteria.RIGHT_JOIN); + + List<Author> authorList = AuthorPeer.doSelect(criteria); + + // Here we get 5 authors: + // the author with one book, the author without books, + // and three times the author with three books + if (authorList.size() != 5) + { + fail("book right join author " + + "incorrect numbers of authors found : " + + authorList.size() + + ", should be 5"); + } + } + + /** + * Test double join with aliases. + * + * @throws Exception if the test fails + */ + public void testDoubleJoinWithAliases() throws Exception + { + if (!supportsRightJoins()) + { + return; + } + + cleanBookstore(); + insertTestData(); + Criteria criteria = new Criteria(); + criteria.addAlias("b", BookPeer.TABLE_NAME); + criteria.addJoin( + BookPeer.AUTHOR_ID, AuthorPeer.AUTHOR_ID, + Criteria.RIGHT_JOIN); + criteria.addJoin( + AuthorPeer.AUTHOR_ID, + new ColumnImpl("b." + BookPeer.AUTHOR_ID.getColumnName()), + Criteria.LEFT_JOIN); + List<Author> authorList = AuthorPeer.doSelect(criteria); + // Here we get 11 authors: + // the author with one book, the author without books, + // and nine times the author with three books + if (authorList.size() != 11) + { + fail("book right join author left join book b: " + + "incorrect numbers of authors found : " + + authorList.size() + + ", should be 11"); + } + } + + /** + * Test a reversed join. + * Reversed means that torque needs to change a right join to a left + * join and change tables to create a valid sql statement. + * + * @throws Exception if the test fails + */ + public void testReverseJoin() throws Exception + { + if (!supportsRightJoins()) + { + return; + } + + cleanBookstore(); + insertTestData(); + Criteria criteria = new Criteria(); + criteria.addAlias("b", BookPeer.TABLE_NAME); + criteria.addJoin(BookPeer.AUTHOR_ID, AuthorPeer.AUTHOR_ID, + Criteria.RIGHT_JOIN); + criteria.addJoin( + new ColumnImpl("b." + BookPeer.AUTHOR_ID.getColumnName()), + AuthorPeer.AUTHOR_ID, + Criteria.RIGHT_JOIN); + + List<Author> authorList = AuthorPeer.doSelect(criteria); + + // Here we get 11 authors: + // the author with one book, the author without books, + // and nine times the author with three books + if (authorList.size() != 11) + { + fail("book right join author left join book b (reversed): " + + "incorrect numbers of authors found : " + + authorList.size() + + ", should be 11"); + } + } + + /** + * Test an implicit inner join with a subselect + * Reversed means that torque needs to change a right join to a left + * join and change tables to create a valid sql statement. + * + * @throws Exception if the test fails + */ + public void testImplicitInnerJoinWithSubselect() throws Exception + { + if (!supportsRightJoins()) + { + return; + } + + cleanBookstore(); + insertTestData(); + + Criteria subselect = new Criteria(); + BookPeer.addSelectColumns(subselect); + subselect.where(BookPeer.TITLE, "Book 1"); + + Criteria criteria = new Criteria(); + criteria.addAlias("b", subselect); + criteria.addJoin( + new ColumnImpl("b." + BookPeer.AUTHOR_ID.getColumnName()), + AuthorPeer.AUTHOR_ID); + + List<Author> authorList = AuthorPeer.doSelect(criteria); + + // Here we get the one author with ine book: + // the author with one book, the author without books, + // and nine times the author with three books + if (authorList.size() != 1) + { + fail("join with subselect: " + + "incorrect numbers of authors found : " + + authorList.size() + + ", should be 1"); + } + assertEquals("Author with one book", authorList.get(0).getName()); + } + + + /** + * Test joins using the XPeer.DoSelectJoinYYY methods + * @throws Exception if the Test fails + */ + public void testDoSelectJoinY() throws Exception + { + cleanBookstore(); + insertTestData(); + + Criteria criteria = new Criteria(); + criteria.addAscendingOrderByColumn(BookPeer.TITLE); + + List<Book> books = BookPeer.doSelectJoinAuthor(criteria); + + assertTrue("books should contain 4 books but contains " + + books.size(), books.size() == 4); + Book bookTwo = books.get(1); + Book bookThree = books.get(2); + assertTrue ("the authors of BookTwo and BookThree" + + " should point to the same instance", + bookTwo.getAuthor() == bookThree.getAuthor()); + } + + /** + * Test joins using the XPeer.DoSelectJoinAllExceptYYY methods + * @throws Exception if the Test fails + */ + public void testDoSelectJoinAllExceptY() throws Exception + { + cleanABC(); + + // setup test data + A a = new A(); + a.setName("test a"); + a.save(); + + B b = new B(); + b.setName("test b"); + b.save(); + + RAb rab = new RAb(); + rab.setName("test rab"); + rab.setA(a); + rab.setB(b); + rab.save(); + + C c = new C(); + c.setName("test c"); + c.setA(a); + c.setB(b); + c.setRAb(rab); + c.save(); + + Criteria criteria = new Criteria(); + criteria.add(APeer.A_ID, a.getAId()); + List<C> list = MyCPeer.doSelectJoinAllExceptA(criteria); + assertTrue("list should contain 1 entry but contains " + + list.size(), list.size() == 1); + + C c1 = list.get(0); + B b1 = c1.getB(); + RAb rab1 = c1.getRAb(); + + assertTrue("The name of c1 should be 'test c' but is " + c1.getName(), + c1.getName().equals("test c")); + assertTrue("The name of b1 should be 'test b' but is " + b1.getName(), + b1.getName().equals("test b")); + assertTrue("The name of rab1 should be 'test rab' but is " + rab1.getName(), + rab1.getName().equals("test rab")); + assertTrue ("The c's of b1 and rab1" + + " should point to the same instance", + b1.getCs().get(0) == rab1.getCs().get(0)); + } + + /** + * Subclass of CPeer to make the doSelectJoinAllExceptA() visible + */ + static class MyCPeer extends CPeer + { + public static List<C> doSelectJoinAllExceptA(Criteria criteria) + throws TorqueException + { + return CPeer.doSelectJoinAllExceptA(criteria); + } + } + + /** + * Deletes all As, Bs, Cs and RAs + * @throws Exception if the cleanup fails + */ + protected void cleanABC() throws Exception + { + // clean C table + Criteria criteria = new Criteria(); + criteria.add(CPeer.C_ID, (Long) null, Criteria.NOT_EQUAL); + CPeer.doDelete(criteria); + + // clean R_AB table + criteria = new Criteria(); + criteria.add(RAbPeer.A_ID, (Long) null, Criteria.NOT_EQUAL); + criteria.add(RAbPeer.B_ID, (Long) null, Criteria.NOT_EQUAL); + RAbPeer.doDelete(criteria); + + // clean A table + criteria = new Criteria(); + criteria.add(APeer.A_ID, (Long) null, Criteria.NOT_EQUAL); + APeer.doDelete(criteria); + + // clean B table + criteria = new Criteria(); + criteria.add(BPeer.B_ID, (Long) null, Criteria.NOT_EQUAL); + BPeer.doDelete(criteria); + } + + /** + * Fills test data into the author and book tables. + * There is one author without books, one author with one book + * and one author with three books. + * + * @throws TorqueException if saving fails. + */ + protected void insertTestData() throws TorqueException + { + // insert test data + Author author = new Author(); + author.setName("Author with one book"); + author.save(); + Book book = new Book(); + book.setAuthor(author); + book.setTitle("Book 1"); + book.setIsbn("unknown"); + book.save(); + + author = new Author(); + author.setName("Author without book"); + author.save(); + + author = new Author(); + author.setName("Author with three books"); + author.save(); + for (int bookNr = 2; bookNr <=4; bookNr++) + { + book = new Book(); + book.setAuthor(author); + book.setTitle("Book " + bookNr); + book.setIsbn("unknown"); + book.save(); + } + + } + + /** + * Returns whether the database supports right joins. + * + * @return true if the database supports right joins, false otherwise. + * + * @throws TorqueException if an error occurs. + */ + protected boolean supportsRightJoins() throws TorqueException + { + if (Torque.getDB(Torque.getDefaultDB()) instanceof DBHsqldb) + { + log.warn("testRightJoins(): " + + "Right joins are not supported by HSQLDB"); + return false; + } + return true; + } +} Copied: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/WhereClauseSubselectTest.java (from r1329656, db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SubselectTest.java) URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/WhereClauseSubselectTest.java?p2=db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/WhereClauseSubselectTest.java&p1=db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SubselectTest.java&r1=1329656&r2=1331179&rev=1331179&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SubselectTest.java (original) +++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/WhereClauseSubselectTest.java Fri Apr 27 02:00:16 2012 @@ -18,13 +18,13 @@ import org.apache.torque.test.Book; import org.apache.torque.test.BookPeer; /** - * Tests subselects. + * Tests subselects in the where clause. * * @version $Id: $ */ -public class SubselectTest extends BaseDatabaseTestCase +public class WhereClauseSubselectTest extends BaseDatabaseTestCase { - private static Log log = LogFactory.getLog(SubselectTest.class); + private static Log log = LogFactory.getLog(WhereClauseSubselectTest.class); Author author1; Author author2; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
