我有以下类和方法如下:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@Component
@Transactional("emp")
public class EmployeeService {
}
@Component
public class HumanResourceManager {
[...]
@Autowired
private EmployeeService employeeService;
@Transactional("emp")
public void checkEmployee(Employee emp) {
[..]
employeeService.saveEmployee(emp);
[...]
}
My Spring config:
<bean id="employeeDataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${employee.driverClassName}" />
<property name="url" value="${employee.url}" />
<property name="username" value="${employee.user}" />
<property name="password" value="${employee.password}" />
</bean>
<bean id="employeeSessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="employeeDataSource" />
<property name="packagesToScan" value="com.xyz.employee.model" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${employee.dialect}</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</prop>
<prop key="hibernate.show.sql">true</prop>
</props>
</property>
</bean>
<bean id="employeeTransactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="employeeSessionFactory" />
<qualifier value="emp" />
</bean>
<tx:annotation-driven transaction-manager="employeeTransactionManager" />
我有例外org.hibernate.exception.LockAcquisitionException: ORA-00060: deadlock detected while waiting for resource
!在异常堆栈跟踪中,此错误发生在方法checkEmployee
。
为什么需要默认的交易传播时会发生此错误?谁能解释一下?