0

I have a controller marked with Transactional annotation. Method join may throw exception, that I'm handling by method handle with help of @ExceptionHandler annotation.

public String join(Model uiModel) {
  ... here exception occures
}

@ExceptionHandler(BalanceException.class)
public String handle() {
    return "someView";
} 

When handle method returns name of a view, then everything is fine. Unfortunately I need to make a redirect to another controller, that requires transaction.

Is it possible to complete this transaction and start new one ?

karpaczio
  • 159
  • 1
  • 3
  • 4
  • If this were pure SQL, you could use "checkpoints". It doesn't look like Spring supports checkpoints: http://static.springsource.org/spring/docs/2.0.7/reference/transaction.html – paulsm4 Jun 17 '12 at 20:37
  • @paulsm4 that's version 2.0.x. Spring is currently at version 3.1.x, so you might check a newer version (these are 5 years old) – Sean Patrick Floyd Jun 17 '12 at 21:03

1 Answers1

0

In my opinion you should never start a transaction in the view layer, but use the service layer to handle transactional logic. That means you should use the @Transactional annotation on your Spring beans in the service layer.

Felix Reckers
  • 1,282
  • 1
  • 14
  • 15