116117118119120121122123124125126
// insert books and authors for (int i = 1; i <= 10; i++) { Author author = new Author(); author.setName("Author " + i); author.save(); assertTrue("authorId should not be 0 after insert", author.getAuthorId() != 0); for (int j = 1; j <= 10; j++) {
371372373374375376377378379380381
{ cleanBookstore(); Author author = new Author(); author.setName("Name"); author.save(); Book book = new Book(); book.setTitle("title"); book.setAuthor(author); book.setIsbn("ISBN");
441442443444445446447448449450451
criteria.add(BookPeer.BOOK_ID, (Long) null, Criteria.NOT_EQUAL); BookPeer.doDelete(criteria, null); Author author = new Author(); author.setName("name"); author.save((Connection) null); } /** * test joins * @throws Exception if the test fails
455456457458459460461462463464465
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();
464465466467468469470471472473474
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++)
468469470471472473474475476477478
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);
610611612613614615616617618619620
cleanBookstore(); // insert test data Author firstAuthor = new Author(); firstAuthor.setName("Author 1"); firstAuthor.save(); Book book = new Book(); book.setAuthor(firstAuthor); book.setTitle("Book 1"); book.setIsbn("unknown"); book.save();
619620621622623624625626627628629
book.setIsbn("unknown"); book.save(); Author secondAuthor = new Author(); secondAuthor.setName("Author 2"); secondAuthor.save(); for (int bookNr = 2; bookNr <=4; bookNr++) { book = new Book(); book.setAuthor(secondAuthor); book.setTitle("Book " + bookNr);
780781782783784785786787788789790
{ cleanBookstore(); Author author = new Author(); author.setName("AuTHor"); author.save(); Criteria criteria = new Criteria(); criteria.add(AuthorPeer.NAME, author.getName().toLowerCase()); criteria.setIgnoreCase(true); List result = AuthorPeer.doSelect(criteria);
816817818819820821822823824825826
public void testSameColumnName() throws Exception { cleanBookstore(); Author author = new Author(); author.setName("Name"); author.save(); author = new Author(); author.setName("NotCorrespondingName"); author.save();