
Plain JDBC Transaction Manager
要使用Spring的事务管理来处理普通的JDBC调用,不能直接从Datasource中获取Connection ,需要使用DataSourceUtils.getConnection
This transaction manager 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 JPA and services which use plain JDBC (without being aware of JPA)! Application code needs to stick to the same simple Connection lookup pattern as with {@link org.springframework.jdbc.datasource.DataSourceTransactionManager} (i.e. {@link org.springframework.jdbc.datasource.DataSourceUtils#getConnection} or going through a {@link org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy}). Note that this requires a vendor-specific {@link JpaDialect} to be configured.
DataSourceUtils.getConnection 重要的逻辑是会从当前线程上下文同步的事务获取关联的Connection,从而统一事务的管理。
评论
新的评论
上一篇
Junit TestInstance
Test Template 用于测试逻辑类似,只是测试数据不同的场景,代码示例 UserIdGeneratorTestInvocationContextProvider 主要实现 TestTemplateInvocationContextProvider 的 provide…
下一篇
Javascript Object Signing and Encryption (JOSE)
JWT JWTs can be represented as either JSON Web Signature (JWS) 3 or a JSON Web Encryption (JWE) 4 objects. Claims within a JWS can be r…
