如果您想买一本书,我想做一种写书评的方法,但是我的代码有问题(在customer.java-> Checksold中),它总是出现相同的通知:“您不能撰写评论,您还没有买这本书”。提示或帮助?谢谢。
-customer.java
plot(fit.rf$finalModel)
-session.java
public boolean checksold(Book book){
TypedQuery<SoldBook> query1 = em.createQuery("SELECT c FROM
SoldBook c ", SoldBook.class);
int index= query1.getResultList().indexOf(book);
return index!=-1;
}
public void review(Customer customer, Book book, String text){
Review c= new Review();
c.setCustomer(customer);
c.setBook(book);
c.setBook(book);
book.addReview(c);
customer.addReview(c);
em.persist(c);
em.merge(book);
em.merge(customer);
}