<!-- 这里直接使用spring对hibernate3支持的sessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<!-- hibernate方言等相关配置 -->
<property name="hibernateProperties">
<props>
<prop key="connection.useUnicode">true</prop>
<prop key="connection.characterEncoding">UTF-8</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
<!-- hbm.xml的映射文件 -->
<property name="mappingResources">
<list>
<value>com/sk/config/SystemUser.hbm.xml</value>
<value>com/sk/config/SystemModule.hbm.xml</value>
<value>com/sk/config/Category.hbm.xml</value>
<value>com/sk/config/Supplier.hbm.xml</value>
<value>com/sk/config/LinkMan.hbm.xml</value>
<value>com/sk/config/PayMethod.hbm.xml</value>
<value>com/sk/config/Item.hbm.xml</value>
<value>com/sk/config/Inquiry.hbm.xml</value>
</list>
</property>
</bean>
<!-- 定义事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager" />
<!-- 配置事务属性 -->
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>*DAO</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
Struts2 + Spring + Hibernate 事务配置
最新推荐文章于 2021-10-31 17:36:38 发布