org.springframework
spring-orm
5.1.7RELEASE
编写配置文件
applicationContext.xml
<cxt:property-placeholder location="classpath:jdbc.properties"/>
<cxt:annotation-config/>
<bean id="dataSource" class="com.mysql.jdbc.jdbc2.option.MysqlDataSource">
<property name="url" value="${url}"/>
<property name="user" value="${user}"/>
<property name="password" value="${password}"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan" value="路径"/>
<property name="hibernateProperties" >
<value>
hibernate.hbm2ddl.auto=update
hibernate.show_sql=true
hobernate.format_sql=true
</value>
</property>
</bean>
<bean class="org.springframework.orm.hibernate5.HibernateTemlate">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
事物打开要加标注@Transactional 事物不回滚加@Rollback(false)
hibernate的事物管理
<bean class="org.springframework.orm.hibernate5.HibernateTransactionManage">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
mybatis的事务管理{
<bean class="org.springframework.jdbc.datasource.DataSourceTransactionManage">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<tx:annotation-driven/>
}
原文:https://www.cnblogs.com/xiao-c-s/p/12422803.html