知识大全 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

相关参考