- 浏览: 2606491 次
- 来自: 杭州
文章分类
- 全部博客 (1190)
- webwork (4)
- 网摘 (18)
- java (104)
- hibernate (1)
- Linux (85)
- 职业发展 (1)
- activeMQ (2)
- netty (15)
- svn (1)
- webx3 (12)
- mysql (81)
- css (1)
- HTML (6)
- apache (3)
- 测试 (2)
- javascript (1)
- 储存 (1)
- jvm (5)
- code (13)
- 多线程 (12)
- Spring (18)
- webxs (2)
- python (119)
- duitang (0)
- mongo (3)
- nosql (4)
- tomcat (4)
- memcached (20)
- 算法 (28)
- django (28)
- shell (1)
- 工作总结 (5)
- solr (42)
- beansdb (6)
- nginx (3)
- 性能 (30)
- 数据推荐 (1)
- maven (8)
- tonado (1)
- uwsgi (5)
- hessian (4)
- ibatis (3)
- Security (2)
- HTPP (1)
- gevent (6)
- 读书笔记 (1)
- Maxent (2)
- mogo (0)
- thread (3)
- 架构 (5)
- NIO (5)
- 正则 (1)
- lucene (5)
- feed (4)
- redis (17)
- TCP (6)
- test (0)
- python,code (1)
- PIL (3)
- guava (2)
- jython (4)
- httpclient (2)
- cache (3)
- signal (1)
- dubbo (8)
- HTTP (4)
- json (3)
- java socket (1)
- io (2)
- socket (22)
- hash (2)
- Cassandra (1)
- 分布式文件系统 (5)
- Dynamo (2)
- gc (8)
- scp (1)
- rsync (1)
- mecached (0)
- mongoDB (29)
- Thrift (1)
- scribe (2)
- 服务化 (3)
- 问题 (83)
- mat (1)
- classloader (2)
- javaBean (1)
- 文档集合 (27)
- 消息队列 (3)
- nginx,文档集合 (1)
- dboss (12)
- libevent (1)
- 读书 (0)
- 数学 (3)
- 流程 (0)
- HBase (34)
- 自动化测试 (1)
- ubuntu (2)
- 并发 (1)
- sping (1)
- 图形 (1)
- freemarker (1)
- jdbc (3)
- dbcp (0)
- sharding (1)
- 性能测试 (1)
- 设计模式 (2)
- unicode (1)
- OceanBase (3)
- jmagick (1)
- gunicorn (1)
- url (1)
- form (1)
- 安全 (2)
- nlp (8)
- libmemcached (1)
- 规则引擎 (1)
- awk (2)
- 服务器 (1)
- snmpd (1)
- btrace (1)
- 代码 (1)
- cygwin (1)
- mahout (3)
- 电子书 (1)
- 机器学习 (5)
- 数据挖掘 (1)
- nltk (6)
- pool (1)
- log4j (2)
- 总结 (11)
- c++ (1)
- java源代码 (1)
- ocr (1)
- 基础算法 (3)
- SA (1)
- 笔记 (1)
- ml (4)
- zokeeper (0)
- jms (1)
- zookeeper (5)
- zkclient (1)
- hadoop (13)
- mq (2)
- git (9)
- 问题,io (1)
- storm (11)
- zk (1)
- 性能优化 (2)
- example (1)
- tmux (1)
- 环境 (2)
- kyro (1)
- 日志系统 (3)
- hdfs (2)
- python_socket (2)
- date (2)
- elasticsearch (1)
- jetty (1)
- 树 (1)
- 汽车 (1)
- mdrill (1)
- 车 (1)
- 日志 (1)
- web (1)
- 编译原理 (1)
- 信息检索 (1)
- 性能,linux (1)
- spam (1)
- 序列化 (1)
- fabric (2)
- guice (1)
- disruptor (1)
- executor (1)
- logback (2)
- 开源 (1)
- 设计 (1)
- 监控 (3)
- english (1)
- 问题记录 (1)
- Bitmap (1)
- 云计算 (1)
- 问题排查 (1)
- highchat (1)
- mac (3)
- docker (1)
- jdk (1)
- 表达式 (1)
- 网络 (1)
- 时间管理 (1)
- 时间序列 (1)
- OLAP (1)
- Big Table (0)
- sql (1)
- kafka (1)
- md5 (1)
- springboot (1)
- spring security (1)
- Spring Boot (3)
- mybatis (1)
- java8 (1)
- 分布式事务 (1)
- 限流 (1)
- Shadowsocks (0)
- 2018 (1)
- 服务治理 (1)
- 设计原则 (1)
- log (0)
- perftools (1)
最新评论
-
Aqu415:
,默认是netty还是hassion?
dubbo入门 -
siphlina:
课程——基于Python数据分析与机器学习案例实战教程分享网盘 ...
Python机器学习库 -
san_yun:
leibnitz 写道hi,我想知道,无论在92还是94版本, ...
hbase的行锁与多版本并发控制(MVCC) -
leibnitz:
hi,我想知道,无论在92还是94版本,更新时(如Puts)都 ...
hbase的行锁与多版本并发控制(MVCC) -
107x:
不错,谢谢!
Latent Semantic Analysis(LSA/ LSI)算法简介
spring 对ibatis的封装通过SqlMapClientTemplate实现。
通常如果我们直接使用ibatis的sqlMapClient进行insert操作或者queryForObject都会抛出sqlSQLException:
处理这种错误很没意思,通过spring的sqlMapClientTemplate只需一行代码:
sqlMapClientTemplate.insert("MS-INSERT-UNREADCOUNT", unreadCount);
看看spring如何帮我们封装的:
最后所有的insert,update,delete,query都通过execute被执行。
通常如果我们直接使用ibatis的sqlMapClient进行insert操作或者queryForObject都会抛出sqlSQLException:
try { cli.insert("MS-INSERT-UNREADCOUNT", unreadCount); } catch (SQLException e) { logger.error("create UnReadCount: ", e); }
处理这种错误很没意思,通过spring的sqlMapClientTemplate只需一行代码:
sqlMapClientTemplate.insert("MS-INSERT-UNREADCOUNT", unreadCount);
看看spring如何帮我们封装的:
public <T> T execute(SqlMapClientCallback<T> action) throws DataAccessException { Assert.notNull(action, "Callback object must not be null"); Assert.notNull(this.sqlMapClient, "No SqlMapClient specified"); // We always need to use a SqlMapSession, as we need to pass a Spring-managed // Connection (potentially transactional) in. This shouldn't be necessary if // we run against a TransactionAwareDataSourceProxy underneath, but unfortunately // we still need it to make iBATIS batch execution work properly: If iBATIS // doesn't recognize an existing transaction, it automatically executes the // batch for every single statement... SqlMapSession session = this.sqlMapClient.openSession(); if (logger.isDebugEnabled()) { logger.debug("Opened SqlMapSession [" + session + "] for iBATIS operation"); } Connection ibatisCon = null; try { Connection springCon = null; DataSource dataSource = getDataSource(); boolean transactionAware = (dataSource instanceof TransactionAwareDataSourceProxy); // Obtain JDBC Connection to operate on... try { ibatisCon = session.getCurrentConnection(); if (ibatisCon == null) { springCon = (transactionAware ? dataSource.getConnection() : DataSourceUtils.doGetConnection(dataSource)); session.setUserConnection(springCon); if (logger.isDebugEnabled()) { logger.debug("Obtained JDBC Connection [" + springCon + "] for iBATIS operation"); } } else { if (logger.isDebugEnabled()) { logger.debug("Reusing JDBC Connection [" + ibatisCon + "] for iBATIS operation"); } } } catch (SQLException ex) { throw new CannotGetJdbcConnectionException("Could not get JDBC Connection", ex); } // Execute given callback... try { return action.doInSqlMapClient(session); } catch (SQLException ex) { throw getExceptionTranslator().translate("SqlMapClient operation", null, ex); } finally { try { if (springCon != null) { if (transactionAware) { springCon.close(); } else { DataSourceUtils.doReleaseConnection(springCon, dataSource); } } } catch (Throwable ex) { logger.debug("Could not close JDBC Connection", ex); } } // Processing finished - potentially session still to be closed. } finally { // Only close SqlMapSession if we know we've actually opened it // at the present level. if (ibatisCon == null) { session.close(); } } }
最后所有的insert,update,delete,query都通过execute被执行。
发表评论
-
Spring JdbcTemplate执行过程分析
2013-07-08 16:38 1610调用入口 调用JdbcTemplate提供的API都会委 ... -
servlet 整合freemarkder
2013-04-18 15:51 1834Servlet与FreeMarker整合 ht ... -
spring schema文档
2013-03-15 17:26 748spring schema 扩展 基于Spri ... -
Spring Resource接口总结
2013-01-17 11:52 765Spring 通过Resource接口对资源进行抽象,资源可 ... -
spring mvc 快速启动
2012-12-30 00:33 1028依赖: <dependency> ... -
JBDC和ibatis的选型总结
2012-12-19 12:30 914最近做搜索,觉得ibatis过于笨重,本想简单的使用JDBC, ... -
spring 框架快速启动
2012-12-18 18:36 10721. 通过maven新建工程 2. 添加依赖包 &l ... -
spring mvc异常吃掉的问题
2012-11-21 16:21 21585今天发现spring mvc把一个view参数匹配异常(org ... -
spring的FactoryBean机制
2012-11-20 16:18 1156spring可以通过的FactoryBean的形式把一个Fac ... -
spring 3.0.5.RELEASE版本的bug
2012-10-26 11:05 1112启动报错: org.springframework.be ... -
Spring 创建bean的过程
2012-10-11 09:42 1046BeanFacotry ApplicationConte ... -
Spring中ref local与ref bean区别:
2012-10-08 11:34 708Spring中ref local与ref bean区别 ... -
spring的类型转换机制(BeanWrapper)
2012-10-02 18:42 2106spring作为一个beanFactory,免不了要做类型转化 ... -
ibatis 配置
2012-08-16 16:34 856<result property="id& ... -
Spring Security授权 AccessDecisionManager
2012-08-13 18:35 8699在前面那篇博客有一段配置: <http aut ... -
Spring Security入门
2012-08-13 15:52 1169参考官方文档(http://www.mossle.com/do ... -
三个类实现通过spring启动web容器
2012-02-27 17:29 2279对于struts2这样的web框架,需要整合spring来管理 ... -
PathMatchingResourcePatternResolver
2012-02-27 16:40 9112PathMatchingResourcePatternReso ... -
Spring 记录
2012-02-27 16:12 1190MethodParameter BeansWrappe ...
相关推荐
访问数据库基本封装(spring/hibernate/ibatis)
Spring+ibatis+struts框架整合+springmvc数据接口封装含数据表可直接运行
ibatis封装
封装通用的Spring3+Struts2+IBatis的CRUD
而iBatis可以为我们做的更多,比如对查询结果的封装等等。虽然不如全自动SQL方便,但是SQL的主动权却在我们开发人员的手中,对SQL优化的掌控则是很直接的。对于Hibernate和iBatis的其它讨论,不是我们探究的范围。...
Spring初探 准备工作 构建Spring基础代码 ... ibatis in Spring Aspect Oriented Programming AOP 概念 AOP in Spring Dynamic Proxy 与Spring AOP CGLib 与 Spring AOP AOP 应用 DAO Support Remoting
一个SSI整合的小例子,CRUD都有,架包全有,导入即可运行,数据库用的是mysql,dao层用了江南白衣的思想,已封装,在此拓展就行,希望能对你有所帮助
(8) spring-orm.jar 这个jar文件包含Spring对DAO特性集进行了扩展,使其支持 iBATIS、JDO、OJB、TopLink,因为Hibernate已经独立成包了,现在不包含在这个包里了。这个jar文件里大部分的类都要依赖 spring-dao.jar...
org.springframework.asm-3.0.0.M4.jar: 提供对ASM(一个字节码框架)的简单封装 org.springframework.expression-3.0.0.M4.jar: spring表达式语言 org.springframework.test-3.0.0.M4.jar: spring提供的一个...
spring-jdbc.jar(必须) :这个jar 文件包含对Spring 对JDBC 数据访问进行封装的所有类。 外部依赖spring-beans,spring-dao。 spring-web.jar(必须) :这个jar 文件包含Web 应用开发时,用到Spring 框架时所需...
org.springframework.asm-3.0.0.M4.jar: 提供对ASM(一个字节码框架)的简单封装 org.springframework.expression-3.0.0.M4.jar: spring表达式语言 org.springframework.test-3.0.0.M4.jar: spring提供的一个...
这个jar文件包含对Spring对JDBC数据访问进行封装的所有类。 (8) spring-orm.jar 这个jar文件包含Spring对DAO特性集进行了扩展,使其支持 iBATIS、JDO、OJB、TopLink,因为Hibernate已经独立成包了,现在不包含在...
这个jar文件包含Spring对DAO特性集进行了扩展,使其支持 iBATIS、JDO、OJB、TopLink,因为Hibernate已经独立成包了,现在不包含在这个包里了。这个jar文件里大部分的类都要依赖 spring-dao.jar里的类,用这个包时你...
其他还有一些特点不是Spring的核心,这里只做简单陈述,如:对JDBC的封装与简化,提供事务管理功能,对O/R mapping工具(hibernate、iBATIS)的整合;提供MVC解决方案,也可以与其他web框架(Struts、JSF)进行整合...
使用ibatis 提供的ORM 机制,对业务逻辑实现人员而言,面对的是纯粹的Java 对象, 这一层与通过Hibernate 实现ORM 而言基本一致,而对于具体的数据操作,Hibernate 会自动生成SQL 语句,而ibatis 则要求...
自己封装包,工具 博文链接:https://atgoingguoat.iteye.com/blog/1600676
mybatis实战教程mybatis in action之五与spring3集成附源码 mybatis实战教程mybatis in action之六与Spring MVC 的集成 mybatis实战教程mybatis in action之七实现mybatis分页源码下载 mybatis实战教程mybatis in ...
☆ Spring ORM:Spring 框架插入了若干个 ORM 框架,从而提供了 ORM 的对象关系工具,其中包括 JDO、Hibernate 和 iBatis SQL Map。所有这些都遵从 Spring 的通用事务和 DAO 异常层次结构。 ☆ Spring Web 模块:...