@Test @ExpectedDataSet public void bookIsAdded() throws PersistenceException { Book book = new Book("Hibernate in Action"); book.setTags(new LinkedHashSet<String>(asList("blog", "java"))); assertNotNull(dao.addBook(book).getId()); }
@Override public Book addBook(Book book) { sessionFactory.getCurrentSession().persist(book); return book; }
HibernateBookDao implements BookDao { @Override public Book addBook(Book book) { sessionFactory.getCurrentSession().persist(book); return book; } }
HibernateBookDao implements BookDao { @Override public Book addBook(Book book) { sessionFactory.getCurrentSession().persist(book); return book; } HibernateBookDao(SessionFactory sessionFactory); }
HibernateBookDao implements BookDao { @Override public Book addBook(Book book) { sessionFactory.getCurrentSession().persist(book); return book; } HibernateBookDao(SessionFactory sessionFactory); @Override Book addBook(Book book); @Override void removeBook(Book book); }
HibernateBookDao implements BookDao { @Override public Book addBook(Book book) { sessionFactory.getCurrentSession().persist(book); return book; } HibernateBookDao(SessionFactory sessionFactory); @Override Book addBook(Book book); @Override void removeBook(Book book);  }