*/
public void testDelete() throws Exception
{
cleanBookstore();
Author author = new Author();
author.setName("Name");
author.save();
Book book = new Book();
book.setTitle("title");
book.setAuthor(author);
book.setIsbn("ISBN");
book.save();
// delete without matching data
Criteria criteria = new Criteria();
criteria.add(
AuthorPeer.AUTHOR_ID,
author.getAuthorId(),
Criteria.NOT_EQUAL);
AuthorPeer.doDelete(criteria);
List authorResult = AuthorPeer.doSelect(new Criteria());
assertTrue("deleted too many records", authorResult.size() == 1);
BookPeer.doDelete(book);
List bookResult = BookPeer.doSelect(new Criteria());
authorResult = AuthorPeer.doSelect(new Criteria());
// check that the book has disappeared
assertTrue("delete by object failed",
bookResult.size() == 0);
// check that the underlying author has not been deleted
assertTrue("delete by object deleted in cascade",
authorResult.size() == 1);
// delete with matching data
criteria.clear();
criteria.add(AuthorPeer.AUTHOR_ID, author.getAuthorId());
AuthorPeer.doDelete(criteria);
authorResult = AuthorPeer.doSelect(new Criteria());
assertTrue("deleted not enough records",
authorResult.size() == 0);
}