我们在Java应用程序中使用TopLink 9.0.3.7。我最近添加了两个我要保存的新表。我将其与一些类似的表进行比较,这些表可以正确保存,而且一切看起来都是一样的。我比较了TopLink Mappling WorkBench 9.0.3.5创建的描述符,它们也是一样的。
来自我们的Action类
submissionDao.transaction(sessionInfo.getClerkReviewSubmission(),
new TransactionBlock<ClerkReviewSubmission>() {
public void merge(ClerkReviewSubmission detached,
ClerkReviewSubmission managed) {
ClerkReviewTask task = mergeTask(new ClerkReviewTask(),
myForm);
for(ClerkReviewCase crCase: sessionInfo.getClerkReviewSubmission().getCases()){
createCaseTask(crCase, task);
}
}
});
private final ClerkReviewCaseTask createCaseTask(ClerkReviewCase crCase,
ClerkReviewTask task) {
ClerkReviewCaseTask caseTask = new ClerkReviewCaseTask();
caseTask.setClerkReviewCase(crCase);
caseTask.setTask(task);
crCase.getCaseTasks().add(caseTask);
task.getCaseTasks().add(caseTask);
return caseTask;
}
来自我们的BaseDAO课程
public T transaction(T detached, TransactionBlock transactionBlock) throws BadDBConnection {
Session session = centralSourceInjector.inject();
UnitOfWork uow = session.acquireUnitOfWork();
try {
T managed = (T)uow.registerObject((T) detached);
transactionBlock.merge(detached, managed);
uow.commit();
session.refreshObject(detached);
return managed;
} catch(OptimisticLockException ole){
uow.rollbackTransaction();
throw ole;
} finally {
uow.release();
}
}
当我调试时,我正在进入BaseDAO类,我在日志中看到的只有:
UnitOfWork(3889394) - 开始工作单元提交 ClientSession(5022219) - 连接(7034305) - 开始交易 ClientSession(5022219) - 连接(7034305) - 提交事务 UnitOfWork(3889394) - 最终工作单元提交 UnitOfWork(3889394) - 发布工作单元
任何建议或指导都将不胜感激。
答案 0 :(得分:0)
一位同事审核了我的代码并建议我添加一行,并修复了问题。他建议我的Action类稍微改变一下:
submissionDao.transaction(sessionInfo.getClerkReviewSubmission(),
new TransactionBlock<ClerkReviewSubmission>() {
public void merge(ClerkReviewSubmission detached,
ClerkReviewSubmission managed) {
ClerkReviewTask task = mergeTask(new ClerkReviewTask(),
myForm);
for (ClerkReviewCase crCase : sessionInfo
.getClerkReviewSubmission().getCases()) {
ClerkReviewCase crCase2 = managed.findCase(crCase
.getIcisCaseId());
createCaseTask(crCase2, task);
}
}
});
}