<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="url"
value="jdbc:oracle:thin:@localhost:1521:orcl">
</property>
<property name="username" value="myoracle"></property>
<property name="password" value="tiger"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>./Users.hbm.xml</value>
<value>./Orderdts.hbm.xml</value>
<value>./Meal.hbm.xml</value>
<value>./Mealseries.hbm.xml</value>
<value>./Orders.hbm.xml</value>
<value>./Admin.hbm.xml</value></list>
</property></bean>
<!-- 声明事物管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- 定义事物通知 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<!-- 定义切面,并将事物通知与切面组合(定义哪些方法应用事物规则) -->
<aop:config>
<!-- 对com.restrant.biz包下的所有类的所有方法都应用事物规则 -->
<aop:pointcut id="bizMethods" expression="execution(* com.restrant.biz.*.*(..))" />
<!-- 将事物通知与切面组合 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethods"/>
</aop:config>
<bean id="UsersDAO" class="UsersDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="OrderdtsDAO" class="OrderdtsDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="MealDAO" class="MealDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="MealseriesDAO" class="MealseriesDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="OrdersDAO" class="OrdersDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="AdminDAO" class="AdminDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean></beans>