必须管理实体才能调用删除
2022-09-04 01:10:48
这是怎么回事?
@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.