我正在通过以下方法进行数据库调用:
@Transactional(rollbackFor = Exception.class, readOnly = false, propagation = Propagation.REQUIRES_NEW)
public void addLogEntry(LogEntry logEntry) throws FatalException
{
mNonTxAlarmService = CONTEXT.getBean(NonTxAlarmService.class);
JobExecution jobExecution = mNonTxAlarmService.getJobExecution(mJobExecution.getId());
logEntry.setJobExecution(jobExecution);
jobExecution.getLogEntries().add(logEntry);
}
其中mNonTxAlarmService.getJobExecution()是一个服务调用,如下所示:
@Transactional(readOnly = true, propagation = Propagation.MANDATORY)
public JobExecution getJobExecution(Integer jobExecutionId)
throws FatalException
{
JobExecution jobExecution = mJobExecutionsService.get(jobExecutionId);
return jobExecution;
}
当它被执行时,我得到以下异常
JobExecution jobExecution = mNonTxAlarmService.getJobExecution(mJobExecution.getId());
:
org.springframework.transaction.IllegalTransactionStateException: No existing transaction found for transaction marked with propagation 'mandatory'
主调度员看起来像这样:
<mvc:annotation-driven />
<tx:annotation-driven />
...
<bean> id="importModule" class="com.xxx.yyy.zzz.aaa.ImportModuleImpl"></bean>
addLogEntry是ImportModuleImpl类中的一个方法。
我在哪里弄错了?