知识大全 Spring+Ibatis+事务处理

Posted 文字

篇首语:怀抱观古今,寝食展戏谑。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 Spring+Ibatis+事务处理相关的知识,希望对你有一定的参考价值。

Spring+Ibatis+事务处理  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!

  applicationContext xml

  view plaincopy to clipboardprint?    <?xml version= encoding= UTF ?>

  <beans xmlns=

  xmlns:xsi= instance

  xsi:schemaLocation= beans xsd >

  <bean id= dataSource

  class= springframework jdbc datasource DriverManagerDataSource >

  <property name= driverClassName >

  <value>oracle jdbc driver OracleDriver</value>

  </property>

  <property name= url >

  <value>jdbc:oracle:thin:@ : :STRUTS</value>

  </property>

  <property name= username >

  <value>STRUTS</value>

  </property>

  <property name= password >

  <value>STRUTS</value>

  </property>

  </bean>

  <bean id= insertDao class= flex samples spring dao InsertCl >

  <property name= sqlMapClient >

  <ref local= sqlMapClient />

  </property>

  </bean>

  <bean name= insertAction

  class= flex samples spring action InsertAction >

  <property name= insertService >

  <ref bean= insertService />

  </property>

  </bean>

  <bean id= insertService

  class= flex samples spring dao InsertService >

  <property name= insertDao >

  <ref local= insertDao />

  </property>

  </bean>

  <bean id= sqlMapClient

  class= springframework orm ibatis SqlMapClientFactoryBean >

  <property name= configLocation >

  <value>

  WEB INF/SqlMapConfig xml

  </value>

  </property>

  <property name= dataSource >

  <ref bean= dataSource />

  </property>

  </bean>

  <bean name= logger

  class= flex samples spring interceptor LoggingInterceptor >

  </bean>

  <bean name= beanNameAutoProxy

  class= springframework aop framework autoproxy BeanNameAutoProxyCreator />

  <bean id= transactionProxy parent= beanNameAutoProxy >

  <property name= beanNames >

  <list>

  <value>insertService</value>

  </list>

  </property>

  <property name= interceptorNames >

  <value>transactionInterceptor</value>

  </property>

  </bean>

  <bean id= logginProxy parent= beanNameAutoProxy >

  <property name= beanNames >

  <list>

  <value>insertDao</value>

  </list>

  </property>

  <property name= interceptorNames >

  <value>logger</value>

  </property>

  </bean>

  <bean id= transactionManager

  class= springframework jdbc datasource DataSourceTransactionManager >

  <property name= dataSource >

  <ref bean= dataSource />

  </property>

  </bean>

  <bean id= transactionInterceptor class= springframework transaction interceptor TransactionInterceptor >

  <property name= transactionManager >

  <ref local= transactionManager />

  </property>

  <property name= transactionAttributes >

  <props>

  <prop key= * >PROPAGATION_REQUIRED Exception</prop>

  </props>

  </property>

  </bean>

  </beans>

  <?xml version= encoding= UTF ?>

  <beans xmlns=

  xmlns:xsi= instance

  xsi:schemaLocation= beans xsd >

  <bean id= dataSource

  class= springframework jdbc datasource DriverManagerDataSource >

  <property name= driverClassName >

  <value>oracle jdbc driver OracleDriver</value>

  </property>

  <property name= url >

  <value>jdbc:oracle:thin:@ : :STRUTS</value>

  </property>

  <property name= username >

  <value>STRUTS</value>

  </property>

  <property name= password >

  <value>STRUTS</value>

  </property>

  </bean>

  <bean id= insertDao class= flex samples spring dao InsertCl >

  <property name= sqlMapClient >

  <ref local= sqlMapClient />

  </property>

  </bean>

  <bean name= insertAction

  class= flex samples spring action InsertAction >

  <property name= insertService >

  <ref bean= insertService />

  </property>

  </bean>

  <bean id= insertService

  class= flex samples spring dao InsertService >

  <property name= insertDao >

  <ref local= insertDao />

  </property>

  </bean>

  <bean id= sqlMapClient

  class= springframework orm ibatis SqlMapClientFactoryBean >

  <property name= configLocation >

  <value>

  WEB INF/SqlMapConfig xml

  </value>

  </property>

  <property name= dataSource >

  <ref bean= dataSource />

  </property>

  </bean>

  <bean name= logger

  class= flex samples spring interceptor LoggingInterceptor >

  </bean>

  <bean name= beanNameAutoProxy

  class= springframework aop framework autoproxy BeanNameAutoProxyCreator />

  <bean id= transactionProxy parent= beanNameAutoProxy >

  <property name= beanNames >

  <list>

  <value>insertService</value>

  </list>

  </property>

  <property name= interceptorNames >

  <value>transactionInterceptor</value>

  </property>

  </bean>

  <bean id= logginProxy parent= beanNameAutoProxy >

  <property name= beanNames >

  <list>

  <value>insertDao</value>

  </list>

  </property>

  <property name= interceptorNames >

  <value>logger</value>

  </property>

  </bean>

  <bean id= transactionManager

  class= springframework jdbc datasource DataSourceTransactionManager >

  <property name= dataSource >

  <ref bean= dataSource />

  </property>

  </bean>

  <bean id= transactionInterceptor class= springframework transaction interceptor TransactionInterceptor >

  <property name= transactionManager >

  <ref local= transactionManager />

  </property>

  <property name= transactionAttributes >

  <props>

  <prop key= * >PROPAGATION_REQUIRED Exception</prop>

  </props>

  </property>

  </bean>

  </beans>InsertAction java

  view plaincopy to clipboardprint?    package flex samples spring action;

  //import java sql Timestamp;

  //import java text SimpleDateFormat;

  import java util List;

  import flex samples spring dao InsertService;

  import flex samples spring bean UserBean;

  import flex samples spring interceptor LoggingInterceptor;

  import mons logging *;

  public class InsertAction

  //##############################################

  private Log log =LogFactory getLog(LoggingInterceptor class);

  private InsertService insertService;

  public InsertService getInsertService()

  return this insertService;

  

  public void setInsertService(InsertService insertService)

  this insertService = insertService;

  

  public void insertData(UserBean user List edu List pro_list) throws Exception

  try

  insertService insertUserInfo(user edu pro_list);

  catch (Exception e)

  (e toString());

  throw e;

  

  

  

  package flex samples spring action;

  //import java sql Timestamp;

  //import java text SimpleDateFormat;

  import java util List;

  import flex samples spring dao InsertService;

  import flex samples spring bean UserBean;

  import flex samples spring interceptor LoggingInterceptor;

  import mons logging *;

  public class InsertAction

  //##############################################

  private Log log =LogFactory getLog(LoggingInterceptor class);

  private InsertService insertService;

  public InsertService getInsertService()

  return this insertService;

  

  public void setInsertService(InsertService insertService)

  this insertService = insertService;

  

  public void insertData(UserBean user List edu List pro_list) throws Exception

  try

  insertService insertUserInfo(user edu pro_list);

  catch (Exception e)

  (e toString());

  throw e;

  

  

  

  InsertCl java

  view plaincopy to clipboardprint?    package flex samples spring dao;

  import java util List;

  import springframework orm ibatis support SqlMapClientDaoSupport;

  import flex samples spring bean UserBean;

  public class InsertCl extends SqlMapClientDaoSupport implements InsertIn

  public void deleteUserInfo(UserBean user)

  this getSqlMapClientTemplate() update( del_data user);

  

  public void insertBaseInfo(UserBean user)

  this getSqlMapClientTemplate() update( insUser user);

  

  public void insertDBInfo(UserBean user)

  this getSqlMapClientTemplate() insert( insDB_Access user);

  this getSqlMapClientTemplate() insert( insDB_SQLserver user);

  this getSqlMapClientTemplate() insert( insDB_ORACLE user);

  this getSqlMapClientTemplate() insert( insDB_Informix user);

  this getSqlMapClientTemplate() insert( insDB_DB user);

  this getSqlMapClientTemplate() insert( insDB_MySQL user);

  this getSqlMapClientTemplate() insert( insDB_otherdb user);

  

  public void insertOSInfo(UserBean user)

  this getSqlMapClientTemplate() insert( insOS_Unix user);

  this getSqlMapClientTemplate() insert( insOS_Linux user);

  this getSqlMapClientTemplate() insert( insOS_MVS user);

  this getSqlMapClientTemplate() insert( insOS_WinXP user);

  this getSqlMapClientTemplate() insert( insOS_WinNT/ user);

  this getSqlMapClientTemplate() insert( insOS_AS/ user);

  this getSqlMapClientTemplate() insert( insOS_otheros user);

  

  public void insertLangInfo(UserBean user)

  this getSqlMapClientTemplate() insert( insLANG_C/C++/VC user);

  this getSqlMapClientTemplate() insert( insLANG_ NET user);

  this getSqlMapClientTemplate() insert( insLANG_COBOL user);

  this getSqlMapClientTemplate() insert( insLANG_VB user);

  this getSqlMapClientTemplate() insert( insLANG_JAVA/JSP user);

  this getSqlMapClientTemplate() insert( insLANG_Apache user);

  this getSqlMapClientTemplate() insert( insLANG_Weblogic user);

  this getSqlMapClientTemplate() insert( insLANG_Framework user);

  this getSqlMapClientTemplate() insert( insLANG_UML user);

  

  public void insertEduInfo(List edu)

  for(int i= ;i<edu size();i++)

  this getSqlMapClientTemplate() insert( insEdu edu get(i));

  

  

  public void insertProInfo(List pro_list)

  for(int i= ;i<pro_list size();i++)

  this getSqlMapClientTemplate() insert( insPro pro_list get(i));

  

  

  

  package flex samples spring dao;

  import java util List;

  import springframework orm ibatis support SqlMapClientDaoSupport;

  import flex samples spring bean UserBean;

  public class InsertCl extends SqlMapClientDaoSupport implements InsertIn

  public void deleteUserInfo(UserBean user)

  this getSqlMapClientTemplate() update( del_data user);

  

  public void insertBaseInfo(UserBean user)

  this getSqlMapClientTemplate() update( insUser user);

  

  public void insertDBInfo(UserBean user)

  this getSqlMapClientTemplate() insert( insDB_Access user);

  this getSqlMapClientTemplate() insert( insDB_SQLserver user);

  this getSqlMapClientTemplate() insert( insDB_ORACLE user);

  this getSqlMapClientTemplate() insert( insDB_Informix user);

  this getSqlMapClientTemplate() insert( insDB_DB user);

  this getSqlMapClientTemplate() insert( insDB_MySQL user);

  this getSqlMapClientTemplate() insert( insDB_otherdb user);

  

  public void insertOSInfo(UserBean user)

  this getSqlMapClientTemplate() insert( insOS_Unix user);

  this getSqlMapClientTemplate() insert( insOS_Linux user);

  this getSqlMapClientTemplate() insert( insOS_MVS user);

  this getSqlMapClientTemplate() insert( insOS_WinXP user);

  this getSqlMapClientTemplate() insert( insOS_WinNT/ user);

  this getSqlMapClientTemplate() insert( insOS_AS/ user);

  this getSqlMapClientTemplate() insert( insOS_otheros user);

  

  public void insertLangInfo(UserBean user)

  this getSqlMapClientTemplate() insert( insLANG_C/C++/VC user);

  this getSqlMapClientTemplate() insert( insLANG_ NET user);

  this getSqlMapClientTemplate() insert( insLANG_COBOL user);

  this getSqlMapClientTemplate() insert( insLANG_VB user);

  this getSqlMapClientTemplate() insert( insLANG_JAVA/JSP user);

  this getSqlMapClientTemplate() insert( insLANG_Apache user);

  this getSqlMapClientTemplate() insert( insLANG_Weblogic user);

  this getSqlMapClientTemplate() insert( insLANG_Framework user);

  this getSqlMapClientTemplate() insert( insLANG_UML user);

  

  public void insertEduInfo(List edu)

  for(int i= ;i<edu size();i++)

  this getSqlMapClientTemplate() insert( insEdu edu get(i));

  

  

  public void insertProInfo(List pro_list)

  for(int i= ;i<pro_list size();i++)

  this getSqlMapClientTemplate() insert( insPro pro_list get(i));

  

  

  

  SqlMapConfig xml

  view plaincopy to clipboardprint?    <?xml version= encoding= UTF ?>

  <!DOCTYPE sqlMapConfig

  PUBLIC ////DTD SQL Map Config //EN

   map config dtd >

  <sqlMapConfig>

  <sqlMap resource= flex/samples/spring/xml/test xml />

cha138/Article/program/Java/ky/201311/28520

相关参考

知识大全 ibatis+spring 集成

  作为开源的Orm对象映射框架ibatis是一个线程安全学习容易但是开发相对于hibernate来说的话就要繁锁些没有很好的工具支持ibatis所有的配置几乎是通过手写这样增加了开发者的难度好啦言归

知识大全 基于Spring+Ibatis的安全线程实现

基于Spring+Ibatis的安全线程实现  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  过去

知识大全 使用Spring解决ibatis多数据源的苦恼

使用Spring解决ibatis多数据源的苦恼  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  i

知识大全 SPring管理Hibernate事务出现异常处理

SPring管理Hibernate事务出现异常处理  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 

知识大全 Spring事务处理及其AOP框架的内幕

Spring事务处理及其AOP框架的内幕  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  ***注

知识大全 开源技术分析:AOP和Spring事务处理

开源技术分析:AOP和Spring事务处理  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  一为什

知识大全 spring 2.0 的事务自动处理

  <aop:config>       <!<aop:advisorid=userManagerTxad

知识大全 在spring中有几种事务管理,分别是什么?

代码管理的事务处理TransactonTemplate的execute方法中的内部类TransactionCallback中的doInTransaction方法中使用publicvoidmake()?

知识大全 Spring的事务

Spring的事务  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  今天对spring的AOP事务

知识大全 Spring声明式事务管理源码解读之事务提交

Spring声明式事务管理源码解读之事务提交  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  其实