java – 使用JPA(postgres)的Spring应用程序中的嵌套事务

使用postgres可以在JPA的@Transactional()中使用PROPAGATION_NESTED吗?我正进入(状态:

org.springframework.transaction.NestedTransactionNotSupportedException:
JpaDialect does not support savepoints - check your JPA provider's capabilities

我试过了:

@Bean
public PlatformTransactionManager transactionManager() {
    JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(entityManagerFactory()
                .getObject());
    transactionManager.setNestedTransactionAllowed(true);
    return transactionManager;
}

但没有成功.

最佳答案 我假设您正在使用Hibernate. Hibernate无法进行NESTED事务.

《java – 使用JPA(postgres)的Spring应用程序中的嵌套事务》

在以下代码摘录中,spring设置savePointManager.但是在Hibernate中没有实现SavepointManager的类.

点赞