springscalatransactionalaspects

Use Spring @Transactional in Scala


We have a mixed Java and Scala project, which uses Spring transaction management. We are using the Spring aspects to weave the files with @Transactional annotated methods.

The problem is, that the Scala classes aren't woven with the Spring transaction aspects. How can I configure Spring to regard the transaction in Scala?


Solution

  • Spring needs your transaction boundary to begin with Spring-managed beans, so this precludes @Transactional Scala classes.

    It sounds like the simple solution is to make service facades which are @Transactional Java classes instantiated as Spring beans. These can delegate to your Scala service/core code.