我们在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)--发布工作单位
如有任何建议或指导,我们将不胜感激。