public void addBookCopy(int bookId, BookCopy copy) throws LibraryException { BookCopyConverter conv = new BookCopyConverter(); BookCopyEntity newCopy = conv.fromBean(copy); newCopy.setBook(em.find(BookEntity.class, (long) bookId)); em.persist(newCopy); // TODO test }
public void addBook(Book book, BookCopy copy) throws LibraryException { BookConverter bookConv = new BookConverter(); BookCopyConverter copyConv = new BookCopyConverter(); BookEntity bookEntity = bookConv.fromBean(book); BookCopyEntity bookCopyEntity = copyConv.fromBean(copy); bookCopyEntity.setBorrowedBy(null); bookCopyEntity.setBook(bookEntity); em.persist(bookEntity); em.persist(bookCopyEntity); }