<!--2.配置SessionFactory-->
<beanid="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!--注入DataSource-->
<propertyname="dataSource"ref="dataSource"/>
<!--映射文件列表-->
<propertyname="mappingResources">
<list>
<value>com/oracle/po/Customer.hbm.xml</value>
</list>
</property>
<!--Hibernate相关属性配置-->
<propertyname="hibernateProperties">
<props>
<propkey="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<propkey="hibernate.show_sql">true</prop>
<propkey="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<!--3.定义事务管理器-->
<beanid="transactionManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<propertyname="sessionFactory"ref="sessionFactory"/>
</bean>
<!--4.配置Spring对Hibernate的事务管理的传播特性-->
<tx:adviceid="txAdvice"transaction-manager="transactionManager">
<tx:attributes>
<tx:methodname="add*"propagation="REQUIRED"/>
<tx:methodname="modify*"propagation="REQUIRED"/>
<tx:methodname="del*"propagation="REQUIRED"/>
<tx:methodname="*"read-only="true"/>
</tx:attributes>
</tx:advice>
<!--5.配置Spring对Hibernate事务的切入点-->
<aop:config>
<aop:pointcutexpression="execution(*com.oracle.dao.*.*(..))"id="allManagerMethod"/>
<aop:advisoradvice-ref="txAdvice"pointcut-ref="allManagerMethod"/>
</aop:config>
您可能感兴趣的文章: