public BookLending lendBook(Book book, Customer customer) {
   BookLending bookLending = new BookLending();
   bookLending.setBook(book);
   bookLending.setCustomer(customer);
   bookLending.setLendingDate(new GregorianCalendar().getTime());
   bookLending.setBookIsLended(true);
   em.persist(bookLending);
   return bookLending;
 }
 public BookLending returnBook(Book book, Customer customer) {
   Query query = em.createNamedQuery("findLendingByCustomerAndBookId");
   query.setParameter("book", book);
   query.setParameter("customer", customer);
   List<BookLending> bookLendings = query.getResultList();
   if (bookLendings.isEmpty()) return null;
   BookLending bookLending = (BookLending) bookLendings.get(0);
   bookLending.setBookIsLended(false);
   bookLending.setReturnDate(new GregorianCalendar().getTime());
   em.persist(bookLending);
   return bookLending;
 }