请有人帮助我。
ManagedBean
public Customer deleteCustomer(Customer customer){
BookstoreManager.getInstance().deleteCustomer(customer);
System.out.println("Customer deleted" + customer.getFirstName());
return null;
}
Business Logik
public Customer deleteCustomer(Customer deletedCustomer) {
try {
em.getTransaction().begin();
Customer customer = new Customer();
em.remove(customer);
em.getTransaction().commit();
} catch (Exception e) {
em.getTransaction().rollback();
e.printStackTrace();
System.out.println("Hello from delete");
}
return null;
}
错误消息
信息:HHH000114:处理删除处理中的瞬态实体
答案 0 :(得分:0)
您的意思是em.remove(deletedCustomer);
吗?
public Customer deleteCustomer(Customer deletedCustomer) {
try {
em.getTransaction().begin();
em.remove(deletedCustomer);
em.getTransaction().commit();
} catch (Exception e) {
em.getTransaction().rollback();
e.printStackTrace();
System.out.println("Hello from delete");
}
return null;
}