beans.xml

<?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:context="http://www.springframework.org/schema/context"
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.0.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<context:component-scan base-package="com.huaweisymantec" />

<context:annotation-config />

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/rmc"/>
<property name="username" value="root" />
<property name="password" value="duan" />
</bean>

<bean id="sf"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>com.huaweisymantec.rmc.core.domain.User</value>
<value>com.huaweisymantec.rmc.core.domain.Equipment</value>
<value>com.huaweisymantec.rmc.core.domain.Info</value>
<value>com.huaweisymantec.rmc.core.domain.RemoteClientPoint</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="heibernat.show_sql">true</prop>
</props>

</property>

</bean>


<bean id="ht" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sf" />
</bean>

<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sf" />
</bean>
 
<aop:config>
<aop:pointcut id="bussinessService"
expression="execution(public * com.huaweisymantec.rmc.core.service.*.*(..))" />
<aop:advisor pointcut-ref="bussinessService" advice-ref="txAdvice" />
</aop:config>

<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="existUser" read-only="true" />
<tx:method name="addUser" propagation="REQUIRED" />
<tx:method name="updateUser" propagation="REQUIRED" />
<tx:method name="addPoint" propagation="REQUIRED" />
<tx:method name="delPoint" propagation="REQUIRED" />
<tx:method name="updatePoint" propagation="REQUIRED" />
<tx:method name="checkExist" propagation="REQUIRED" />
<tx:method name="delUser" propagation="REQUIRED" />
<tx:method name="saveEquipment" propagation="REQUIRED"/>
<tx:method name="deleteEquipment" propagation="REQUIRED"/>
<tx:method name="updateEquipment" propagation="REQUIRED"/>
<tx:method name="findEquipment" propagation="REQUIRED"/>
<tx:method name="getEquipment" propagation="REQUIRED"/>
<tx:method name="isExitEquipment" read-only="true" />
</tx:attributes>
</tx:advice>
</beans>

你可能感兴趣的:(Hibernate,xml)