There is a hard dependency between @Transactional and JPA (eg. spring-boot-starter-data-jpa) to get the expected behavior. Unfortunately there is no exception or at least warning if you use Transactional annotation without JPA dependency installed. All is silently ignored and it can lead to unexpected behavior in eg. DB connection pools.

Comment From: snicoll

There is a hard dependency between @Transactional and JPA (eg. spring-boot-starter-data-jpa) to get the expected behavior.

What makes you think that? As far as I am aware, transaction support in Spring Boot is not tied to JPA and can work with plain JDBC. If you believe differently, please share a small sample that demonstrates the problem.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: Davio

Note that transactions are not strictly tied to database interactions.

For instance, if you use @Transactional with RabbitMQ (and use a transactional channel) and you send a message, the message is only sent at the completion of the transaction.

So you can do (simplified for clarity):

@Transactional
public void testRabbit() {
  rabbitTemplate.send("Hello")
  throw new IllegalStateException("test");
}

And this will cause the message to not be sent because of the runtime exception causing a rollback on the transaction.

So in short: while it's true that transactions are generally used for database interaction, other external systems and libraries can partake in them.

However, I do wonder if there should be a warning or runtime error if @Transactional is effectively a no-op because a transaction manager is not available.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.