When configuring Spring transaction through xml, is it good to bind interfaces or concrete
classes for transaction? I was thinking that we should have interfaces mapped for
transaction handling, but i found this from Spring documentation:
“The Spring team’s recommendation is that you only annotate concrete classes with the
@Transactional annotation”.
Please share your thoughts.
Transaction boundaries are implementation details, therefore they should be specified by implementation rather than by interface.
For example, imagine that in some complex case you need to use programmatic transaction management (
TransactionTemplate) rather than@Transactionalfor one of your methods. If you have@Transactionalat interface level, it won’t be possible.