Spring4集成Hibernate5
Hibernate5相比hibernate4做了一些调整会涉及到配置文件的变更
Hibernate官方给出的文档中描述了这些变更
The transaction SPI underwent a major redesign as part of 5.0 as well. From a user perspective this generally only comes into view in terms of configuration. Previously applications would work with the different backend transaction stratagies directly via the
org.hibernate.TransactionAPI. In 5.0 a level of indirection has been added here. The API implementation oforg.hibernate.Transactionis always the same now. On the backend, theorg.hibernate.Transactionimpl talks to aorg.hibernate.resource.transaction.TransactionCoordinatorwhich represents the "transactional context" for a given Session according to the backend transaction strategy. Users generally do not need to care about the distinction.The change is noted here because it might affect your bootstrap configuration. Whereas previously applications would specify
hibernate.transaction.factory_classand refer to aorg.hibernate.engine.transaction.spi.TransactionFactoryFQN, with 5.0 the new contract isorg.hibernate.resource.transaction.TransactionCoordinatorBuilderand is specified using thehibernate.transaction.coordinator_classsetting. Seeorg.hibernate.cfg.AvailableSettings.TRANSACTION_COORDINATOR_STRATEGYjavaDocs for additional details.The following short-names are recognized:
jdbc::(the default) says to use JDBC-based transactions (org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl)jta::says to use JTA-based transactions (org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl)See the User Guide for additional details.
hibernate4中事务管理配置方式
hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext
hibernate5中使用以下方式
hibernate.transaction.coordinator_class=jdbc
配置的值使用短名称,不再使用完整的类名,jdbc代表org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl,
jta代表org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl
标签:PublicCMS
2条评论
😍
全英文呢啊!