<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.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="driverClassName" value="${jdbc.driverClassName}" />
<!-- 连接的用户名 -->
<property name="username" value="${jdbc.username}" />
<!-- 连接的用户密码 -->
<property name="password" value="${jdbc.password}" />
<!-- 连接的url地址 -->
<property name="url" value="${jdbc.url}" />
<!--数据库的连接的最小值 -->
<!--数据库的连接的最大值 -->
</bean>
<!-- 怎么与hibernate整合的 -->
<!-- sessionFactory工厂 -->
<bean id="localSessionFactoryBean"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 数据库连接的数据源 -->
<property name="dataSource" ref="dataSource" />
<!-- hibernate的映射文件配置 -->
<property name="mappingResources">
<array>
<value>www/csdn/weibo/domain/Admins.hbm.xml</value>
<value>www/csdn/weibo/domain/AtUsers.hbm.xml</value>
<value>www/csdn/weibo/domain/Collections.hbm.xml</value>
<value>www/csdn/weibo/domain/Comments.hbm.xml</value>
<value>www/csdn/weibo/domain/Messages.hbm.xml</value>
<value>www/csdn/weibo/domain/Pictures.hbm.xml</value>
<value>www/csdn/weibo/domain/PrivateLetter.hbm.xml</value>
<value>www/csdn/weibo/domain/Relation.hbm.xml</value>
<value>www/csdn/weibo/domain/UserInfo.hbm.xml</value>
<value>www/csdn/weibo/domain/Users.hbm.xml</value>
</array>
</property>
<!-- hibernate的属性配置 -->
<property name="hibernateProperties">
<props>
<prop key="show_sql">true</prop>
<prop key="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
</props>
</property>
</bean>
<!-- hibernate封装的模版类 -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="localSessionFactoryBean"/>
</bean>
<!-- 事务管理器 -->
<bean id="hibernateTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="localSessionFactoryBean"/>
</bean>
<!-- 事务的通知-->
<tx:advice id="txAdvice" transaction-manager="hibernateTransactionManager">
<!-- 事务的属性 -->
<tx:attributes>
<!-- 事务的具体执行方法 -->
<tx:method name="save*" propagation="REQUIRED" isolation="DEFAULT"/>
<tx:method name="delete*" propagation="REQUIRED" isolation="DEFAULT"/>
<tx:method name="update*" propagation="REQUIRED" isolation="DEFAULT"/>
<tx:method name="get*" propagation="REQUIRED" isolation="DEFAULT" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 切面 -->
<aop:config>
<aop:pointcut expression="execution(* *..service.*.*(..))" id="mycut" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="mycut" />
</aop:config>
</beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.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="driverClassName" value="${jdbc.driverClassName}" />
<!-- 连接的用户名 -->
<property name="username" value="${jdbc.username}" />
<!-- 连接的用户密码 -->
<property name="password" value="${jdbc.password}" />
<!-- 连接的url地址 -->
<property name="url" value="${jdbc.url}" />
<!--数据库的连接的最小值 -->
<!--数据库的连接的最大值 -->
</bean>
<!-- 怎么与hibernate整合的 -->
<!-- sessionFactory工厂 -->
<bean id="localSessionFactoryBean"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 数据库连接的数据源 -->
<property name="dataSource" ref="dataSource" />
<!-- hibernate的映射文件配置 -->
<property name="mappingResources">
<array>
<value>www/csdn/weibo/domain/Admins.hbm.xml</value>
<value>www/csdn/weibo/domain/AtUsers.hbm.xml</value>
<value>www/csdn/weibo/domain/Collections.hbm.xml</value>
<value>www/csdn/weibo/domain/Comments.hbm.xml</value>
<value>www/csdn/weibo/domain/Messages.hbm.xml</value>
<value>www/csdn/weibo/domain/Pictures.hbm.xml</value>
<value>www/csdn/weibo/domain/PrivateLetter.hbm.xml</value>
<value>www/csdn/weibo/domain/Relation.hbm.xml</value>
<value>www/csdn/weibo/domain/UserInfo.hbm.xml</value>
<value>www/csdn/weibo/domain/Users.hbm.xml</value>
</array>
</property>
<!-- hibernate的属性配置 -->
<property name="hibernateProperties">
<props>
<prop key="show_sql">true</prop>
<prop key="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
</props>
</property>
</bean>
<!-- hibernate封装的模版类 -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="localSessionFactoryBean"/>
</bean>
<!-- 事务管理器 -->
<bean id="hibernateTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="localSessionFactoryBean"/>
</bean>
<!-- 事务的通知-->
<tx:advice id="txAdvice" transaction-manager="hibernateTransactionManager">
<!-- 事务的属性 -->
<tx:attributes>
<!-- 事务的具体执行方法 -->
<tx:method name="save*" propagation="REQUIRED" isolation="DEFAULT"/>
<tx:method name="delete*" propagation="REQUIRED" isolation="DEFAULT"/>
<tx:method name="update*" propagation="REQUIRED" isolation="DEFAULT"/>
<tx:method name="get*" propagation="REQUIRED" isolation="DEFAULT" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 切面 -->
<aop:config>
<aop:pointcut expression="execution(* *..service.*.*(..))" id="mycut" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="mycut" />
</aop:config>
</beans>