[Relearn Spring] 4 Transaction Management

Annotation based Management

  1. Use @Transactional along with <tx:annotaion-driven/>

  2. Note: Calling a @Transactional method in the same class will not take effect if you are not using AspectJ for AOP.

It’s OK to use HibernateTransactionManager with JdbcTemplate

  here it is:

引用
This transaction manager is appropriate for applications that use a single Hibernate SessionFactory for transactional data access, but it also supports direct DataSource access within a transaction (i.e. plain JDBC code working with the same DataSource). This allows for mixing services which access Hibernate and services which use plain JDBC (without being aware of Hibernate)! Application code needs to stick to the same simple Connection lookup pattern as with DataSourceTransactionManager (i.e. DataSourceUtils.getConnection(javax.sql.DataSource) or going through a TransactionAwareDataSourceProxy).

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.