首页 > 编程语言 > 详细

ssh3,hibernate和spring

时间:2020-03-05 21:51:45      阅读:48      评论:0      收藏:0      [点我收藏+]

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/>
}

ssh3,hibernate和spring

原文:https://www.cnblogs.com/xiao-c-s/p/12422803.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!