public void testSameObjectRelations() throws Exception
{
Author author = new Author();
author.setAuthorId(AUTHOR_1_ID);
Book book = new Book();
book.setBookId(BOOK_1_ID);
author.addBook(book);
book.setAuthor(author);
// check one roundtrip from author
assertTrue("author from book should be the same object as author",
author == book.getAuthor());
AuthorBean authorBean = author.getBean();
BookBean bookBean = (BookBean) authorBean.getBookBeans().get(0);
assertTrue("authorBean from BookBean should be the same "
+ "object as authorBean",
bookBean.getAuthorBean() == authorBean);
author = Author.createAuthor(authorBean);
book = (Book) author.getBooks().get(0);
assertTrue("author from book should be the same object as author "
+ "after creating from bean",
author == book.getAuthor());
// check one roundtrip from book
assertTrue("book from author should be the same object as book",
book == author.getBooks().get(0));
bookBean = book.getBean();
authorBean = bookBean.getAuthorBean();
assertTrue("bookBean from authorBean should be the same "
+ "object as bookBean",
authorBean.getBookBeans().get(0) == bookBean);
book = Book.createBook(bookBean);
author = book.getAuthor();
assertTrue("book from author should be the same object as book "
+ "after creating from bean",
author.getBooks().get(0) == book);
}