Nathing
mingwjj
全部博文(111)
j2se(1)
hibernate(0)
2016年(2)
2015年(1)
2014年(31)
2012年(2)
2011年(9)
2010年(36)
2009年(30)
kgdjszx
备案出行
hzlzy
zhaoyh
zyd10137
wddwr730
2_gougou
shenhp
yingyife
分类: Java
2010-11-01 13:54:52
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="" xmlns:xsi="" xmlns:aop="" xmlns:tx="" xsi:schemaLocation=" /spring-beans-2.0.xsd /spring-aop-2.0.xsd /spring-tx-2.0.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://127.0.0.1/d2school"/> <property name="username" value="root"/> <property name="password" value="root"/> </bean> <!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <!-- 配置事务的传播特性 --> <tx:advice id="txAdvice" transaction-manager="transactionManager" > <tx:attributes> <!-- 在开发的时候可以这样定义,但部署的时候一定要详细定义 --> <tx:method name="*" propagation="REQUIRED"/> <!-- <tx:method name="add*" propagation="REQUIRED"/> <tx:method name="del*" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED"/> <tx:method name="deploy*" propagation="REQUIRED"/> <tx:method name="*" read-only="true"/> --> </tx:attributes> </tx:advice> <!-- 配置哪些类哪些方法使用事务 --> <aop:config> <aop:pointcut id="allServiceMethod" expression="execution(* com.jj.serializ.manager.*.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="allServiceMethod"/> </aop:config> <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="configLocation"><value>classpath:sqlMapConfig.xml</value></property> </bean> <bean id="reportDAO" class="com.jj.serializ.dao.impl.ReportDAOImpl"> <property name="sqlMapClient" ref="sqlMapClient"></property> </bean> </beans>
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE sqlMapConfigPUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"""><!-- Always ensure to use the correct XML header as above! --><sqlMapConfig> <sqlMap resource="com/jj/serializ/model/Report.xml" /> </sqlMapConfig>
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Mao 2.0//EN" ""> <sqlMap> <typeAlias alias="Report" type="com.jj.serializ.model.Report"/> <select id="selectAllReport" resultClass="Report"> select * from champions_2008 </select> </sqlMap>
import java.util.List;import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;import com.jj.serializ.dao.ReportDAO;import com.jj.serializ.model.Report;public class ReportDAOImpl extends SqlMapClientDaoSupport implements ReportDAO{ @SuppressWarnings("unchecked") public List<Report> list() { return getSqlMapClientTemplate().queryForList("selectAllReport"); }}
上一篇:spring集成struts1
下一篇:Ibtis
chinaunix网友2010-11-01 17:46:09
很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com
登录 注册