see https://github.com/seata/seata/pull/5092

The HibernateJpaAutoConfiguration is after the DataSourceTransactionManagerAutoConfiguration when reference seata. It causes the bean of the TransactionManager to be JdbcTransactionManager instead of JpaTransactionManager

Comment From: wangliang181230

I think the HibernateJpaAutoConfiguration must be adding @AutoConfigureBefore(DataSourceTransactionManagerAutoConfiguration.class)

Comment From: wilkinsona

DataSourceTransactionManagerAutoConfiguration is @AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE). This means that it will be ordered last once any @AutoConfigureBefore and @AutoConfigureAfter constraints have been taken into account. This should mean that the DataSourceTransactionManager is used as a fallback when no other transaction manager's available. As far as I can tell, the ordering requirements in Seata caused DataSourceTransactionManagerAutoConfiguration to ordered before HibernateJpaAutoConfiguration and https://github.com/seata/seata/pull/5092 will fix it. In my opinion, this is the right way to solve the problem. It isn't scalable for every auto-configuration that defines a transaction manager to reference DataSourceTransactionManagerAutoConfiguration.

Comment From: wangliang181230

Oh, I seem to have misunderstood. I always thought that the default value of order of the AutoConfiguration was Ordered. LOWEST_PRECEDENCE. But it is actually 0.

Thank you for your answer.

Comment From: wangliang181230

I think about it carefully. Sorting according to order is very unstable and will be destroyed by @AutoConfigureAfter and @AutoConfigureBefore. Just like reference seata:1.5.2, jdbc is before then jpa. Therefore, I still think it is necessary to add @AutoConfigureBefore(DataSourceTransactionManagerAutoConfiguration.class)

Comment From: wilkinsona

Sorting according to order is very unstable and will be destroyed by @AutoConfigureAfter and @AutoConfigureBefore.

That's not the case. The @AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE) on DataSourceTransactionManagerAutoconfiguration ensures that it goes last among all of the auto-configurations that would share the same position based on their @AutoConfigureAfter and @AutoConfigureBefore.