<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- 用 MYSQL 
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost/ibatis"/>
<property name="username" value="root"/>
<property name="password" value="123456"/>
</bean>
-->

<!--  用MSSQL-->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
<property name="url" value="jdbc:sqlserver://localhost:1433;databasename=ibatis"/>
<property name="username" value="sa"/>
<property name="password" value="123456"/>
</bean>
 
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:sql-map-config.xml"></property>
<property name="useTransactionAwareDataSource" value="true"></property>
</bean> <bean id="trans" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>

<tx:advice id="advice" transaction-manager="trans">
<tx:attributes>
<tx:method name="find*" read-only="true"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="add*" read-only="true"/>
<tx:method name="*"  read-only="true"/>
</tx:attributes>
</tx:advice>

<aop:config>
<aop:pointcut expression="execution(* pxl.service.impl.*.*(..))" id="pcut"/>
<aop:advisor advice-ref="advice" pointcut-ref="pcut"/>
</aop:config>

<bean id="baseDao" class="pxl.dao.impl.BaseDao" abstract="true">
<property name="sqlMapClient">
<ref local="sqlMapClient"/>
</property>
</bean>

<bean id="cityDao" class="pxl.dao.impl.CityDao" parent="baseDao"/>
<bean id="streatDao" class="pxl.dao.impl.StreatDao" parent="baseDao"/>


<bean id="cityService" class="pxl.service.impl.CityService">
<property name="cityDao" ref="cityDao"/>
</bean>
 
<bean id="streatService" class="pxl.service.impl.StreatService">
<property name="streatDao" ref="streatDao"/>
</bean>

</beans>
我用MS SQL2005 时候
我的add*为只读的事务  但是add记录的时候 照样能成功搞了很长时间了 还是美结果
最后 把数据库换成MYSQL
事务是只读的时候报错 说明是正常的 也就是说在MYSQL里面是好的但是 为什么SQL2005就不行了呢  貌似管理不了事物一样