这里发生了什么?实体必须设法调用删除
@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