We are using TopLink 9.0.3.7 in our Java application. I have recently added two new tables I am trying to save to. I am comparing this to some similar tables that save correctly and everything appears to be the same. I have compared the descriptors created by TopLink Mappling WorkBench 9.0.3.5 and they appear the same too.
From our Action class
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;
}
From our BaseDAO class
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();
}
}
When I debug I am reaching into the BaseDAO class and all I see in the logs are:
UnitOfWork(3889394)--begin unit of work commit ClientSession(5022219)--Connection(7034305)--begin transaction ClientSession(5022219)--Connection(7034305)--commit transaction UnitOfWork(3889394)--end unit of work commit UnitOfWork(3889394)--release unit of work
Any Suggestions or guidance would be appreciated.
A co-worker reviewed my code and suggested I add one additional line and it fixed the problem. He suggested a small change in my Action class:
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);
}
}
});
}