這裏發生了什麼?實體必須設法調用刪除
@Stateless
@LocalBean
public class AppointmentCommentDao {
public void delete(long appointmentCommentId) {
AppointmentComment ac = em.find(AppointmentComment.class, appointmentCommentId);
if (ac != null)
{
em.merge(ac);
em.remove(ac);
}
}
@PersistenceContext
private EntityManager em;
}
在調用remove
我得到一個IllegalArgumentException
與消息是Entity must be managed to call remove: ...., try merging the detached and try the remove again.
與em.find(...)方法解決了這個問題。 – 2015-10-07 13:18:37