Announcement Announcement Module
No announcement yet.
Clarification of behavior using @Transactional with inner method calls Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Clarification of behavior using @Transactional with inner method calls

    Hey all,

    I am currently checking Spring Forums and StackOverflow to get a definitive answer on what Spring's @Transactional behavior should be in the following situation.

    I have two services, Service A and Service B, they look like this:
    class ServiceA {
      private ServiceB serviceB;
      public void methodA() {
        try {
        catch (RuntimeException e) {
    class ServiceB {
      public void methodB() {
        // do stuff
    Additional Info: I use a JpaTransactionManager together with EclipseLink 2.2 inside a Spring 3.1 container with a PostgresQL 9.1 database.

    The behavior I see in my code is that the transaction that is started in ServiceA.methodA() is set to rollbackOnly when a RuntimeException occurs in ServiceB.methodB(), even though it is explicitly set to not cause a rollback. From my understanding this seems reasonable because the transaction boundary (ServiceA.methodA()) defines the rollback-behavior and I don't expect this to change for some intermediate calls once the transaction is defined. But... this post at StackOverflow states it to be otherwise:

    So, is the behavior I see correct, is it a bug in my setup or a change in behavior between Spring 2.5 and 3.1?

    Thanks for the clarification