First, take a look at the source code:
Hibernate transaction:
org.springframework.orm.hibernate5.HibernateTransactionManager
DoBegin() processing code: process hibernate's sessionholder:
The holder source code of the datasource:
Determine whether there is a dataSource. If there is a dataSource, bind it to the connectionholder
Transaction processing in mybatis:
Data sourceutils is used to obtain the connection, while data sourceutils is read from the connectionholder
Therefore, in order to support both hibernate and mybatis transactions, the following configurations need to be made:
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
<property name="dataSource">
<ref bean="dataSource"/>
</property>
</bean>
It means that Hibernate transaction manager is used to manage all transactions, and the default datasource is hosted in the data source of Hibernate.