Is it possible to have PROPAGATION_NESTED
in @Transactional()
with JPA using postgres? I am getting:
org.springframework.transaction.NestedTransactionNotSupportedException:
JpaDialect does not support savepoints - check your JPA provider's capabilities
I tried:
@Bean
public PlatformTransactionManager transactionManager() {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(entityManagerFactory()
.getObject());
transactionManager.setNestedTransactionAllowed(true);
return transactionManager;
}
But with no success.
Not all transaction managers support nested transactions. Spring supports this out of the box only with the JDBC DataSourceTransactionManager, which is what we'll cover.
The @Transactional annotation is the metadata that specifies the semantics of the transactions on a method. We have two ways to rollback a transaction: declarative and programmatic. In the declarative approach, we annotate the methods with the @Transactional annotation.
No. It doesn't flush data directly to a database until and unless we explicitly call flush and commit method. It's flush directly flush data to a database. It doesn't flush data directly to a database, therefore, changes will not be visible outside the transaction unless we explicitly call commit() in this transaction.
I am assuming that you are using Hibernate. NESTED transactions is not possible with Hibernate.
In the following code excerpt, spring sets savePointManager. But there is no class implementing SavepointManager
in Hibernate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With