该场景是一个更新实体,我按如下方式编写代码:
try {
pm = PMF.get().getPersistenceManager();
BloodDonor bloodDonor = pm.getObjectById(BloodDonor.class,
bean.getBloodDonorSeq());
bloodDonor.setFirstName(firstName);
finally {
try {
if (pm != null && pm.isClosed() == false)
pm.close();
} catch (Exception e) {
log.severe("Exception in finally of execute of updateDonor");
}
log.info("end of updateDonor");
}
因此,当它在pm结束时点击finally块时,更改将被写入数据存储区。我的问题是在某种情况下说我想要在关闭pm之前回滚我在try块中做的任何事情然后该怎么做?换句话说,如果我想取消try块的效果,那么我该如何通知pm清除所有?