ibatis

iBATIS的自定义类型处理器TypeHandlerCallback解决乱码

荒凉一梦 提交于 2019-11-27 04:17:21
转自: http://jackandroid.iteye.com/blog/614032 iBATIS的自定义类型处理器TypeHandlerCallback BATIS提供TypeHandlerCallback来提供对用户自定义类型的处理。 Java代码 public interface TypeHandlerCallback { public void setParameter(ParameterSetter setter, Object parameter) throws SQLException; public Object getResult(ResultGetter getter) throws SQLException; public Object valueOf(String s); } 它主要利用上述的三个方法来对自定义类型转换提供支持。下面我详细讲述下如何利用其来对自定义数据进行支持。 演示的内容主要是将表单中gender列中的字段转换为自己需要的内容(female<->女,male<->男) 1.数据库表people Sql代码 create table people( id int not null auto_increment, gender varchar (10), constraint pk primary key (id) ); insert

springmvc+ibatis整合示例(转)

无人久伴 提交于 2019-11-27 04:16:58
转自: http://www.cnblogs.com/archie2010/archive/2011/05/06/2038792.html SpringMVC与Ibatis框架整合所使用版本 Ibatis 2.3.4 Spring 3.0 web.xml <? xml version="1.0" encoding="UTF-8" ?> < web-app version ="2.5" xmlns ="http://java.sun.com/xml/ns/javaee" xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation ="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" > <!-- 字符过滤_防止添加到数据库中的数据为乱码 --> < filter > < filter-name > characterEncodingFilter </ filter-name > < filter-class > org.springframework.web.filter.CharacterEncodingFilter </ filter-class > < init-param

一次栈溢出问题的排查 StackOverflowError

倖福魔咒の 提交于 2019-11-26 22:28:16
栈溢出的原因 在解决栈溢出问题之前,我们首先需要知道一般引起栈溢出的原因,主要有以下几点: 是否有递归调用,循环依赖调用 是否有大量循环或死循环 全局变量是否过多 局部变量过大,如:数组、List、Map数据过大 问题现象 我们一个很老的接口(近一年没有动过)在线上运行一段时间后报了 StackOverflowError 栈溢出,其他接口又能正常提供服务,错误日志: java.lang.StackOverflowError org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1303) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:977) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) org

Return HashMap in mybatis and use it as ModelAttribute in spring MVC

送分小仙女□ 提交于 2019-11-26 22:16:06
问题 I want to display list of categories in my Jsp page using spring mvc @modelAttribute. In my mapper.xml file is <select id="selectAllCategories" resultMap="BaseResultMap"> select id, name from categories </select> In my Mapper.java class I have method List<Map<String, String>> selectAllCategories(); I want to have a method like this: Map<Integer, String>`selectAllCategories(); instead of List<Map<>> , is that possible? 回答1: You want to get a Map<Integer,String> where the Integer is the id and

Hibernate, iBatis, Java EE or other Java ORM tool

南楼画角 提交于 2019-11-26 19:18:58
We're in the process of planning a large, enterprise application. We're focusing our efforts on evaluating hibernate after experiencing the pains of J2EE. It looks like the new Java EE API is simpler. I've also read some good things about Hibernate and iBatis. Our team has little experience with any of the frameworks. There are 5 main comparisong points I'd like to determine Learning Curve/Ease of Use Productivity Maintainability/Stability Performance/Scalability Ease of Troubleshooting If you were to manage a team of ~6 developers with J2EE experience which ORM tool would you use and why?

Hibernate Vs iBATIS [closed]

无人久伴 提交于 2019-11-26 18:43:05
问题 For our new product re-engineering, we are in the process of selecting the best framework from Java. As the consideration is to go for database agnostic approach for model, we are working on options between Struts + Spring with iBATIS or Hibernate. Please advice which is best as both offer persistence. 回答1: Ibatis and Hibernate are quite different beasts. The way I tend to look at it is this: Hibernate works better if your view is more object-centric . If however you view is more database

ibatis和hibernate区别 [转]

让人想犯罪 __ 提交于 2019-11-26 15:03:47
http://zhidao.baidu.com/question/99674664.html?fr=qrl&cid=870&index=1 ibatis:sql需要自己写 hibernate:sql自动生成 上面是最大的区别,下面是一些细节. 选择Hibernate还是iBATIS都有它的道理: Hibernate的特点: Hibernate功能强大,数据库无关性好,O/R映射能力强,如果你对Hibernate相当精通,而且对Hibernate进行了适当的封装,那么你的项目整个持久层代码会相当简单,需要写的代码很少,开发速度很快,非常爽。以数据库字段一一对应映射得到的PO和Hibernte这种对象化映射得到的PO是截然不同的,本质区别在于这种PO是扁平化的,不像Hibernate映射的PO是可以表达立体的对象继承,聚合等等关系的,这将会直接影响到你的整个软件系统的设计思路。Hibernate对数据库结构提供了较为完整的封装,Hibernate的O/R Mapping实现了POJO 和数据库表之间的映射,以及SQL 的自动生成和执行。程序员往往只需定义好了POJO 到数据库表的映射关系,即可通过Hibernate 提供的方法完成持久层操作。程序员甚至不需要对SQL 的熟练掌握, Hibernate/OJB 会根据制定的存储逻辑,自动生成对应的SQL 并调用JDBC 接口加以执行

[mybatis]It&apos;s likely that neither a Result Type nor a Result Map was specified

為{幸葍}努か 提交于 2019-11-26 14:52:27
Caused by: org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement 'com.asiainfo.path.mapper.RoadPriceMapper.selectMinMilesByEnStationId'. It's likely that neither a Result Type nor a Result Map was specified. 解决 必须要有resultType https://blog.csdn.net/you23hai45/article/details/77982358 parameterType="java.lang.String" parameterType="String" parameterType="string" resultType="string" String的写法,都可 来源: oschina 链接: https://my.oschina.net/u/2464371/blog/3072618

ibatis 核心原理解析!

天大地大妈咪最大 提交于 2019-11-26 12:04:30
摘自: https://www.cnblogs.com/justdojava/p/11271555.html 关注下方公众号,可以在公众号后台回复“博客园”,免费获得作者 Java 知识体系/面试必看资料。 最近查找一个生产问题的原因,需要深入研究 ibatis 框架的源码。虽然最后证明问题的原因与 ibatis 无关,但是这个过程加深了对 ibatis 框架原理的理解。 这篇文章主要就来讲讲 ibatis 框架的原理。 可能现在很多人已不再使用 ibatis 或者说也没听 ibatis,不过肯定了解过 Mybatis。ibatis 就是 Mybatis框架的前身,虽然 ibatis 框架已经比较老,但是其核心功能与 Mybatis 一致。 ibatis 解决的痛点 我们先看一个使用 JDBC 查询的例子。 使用原生 JDBC 查询,存在两个痛点: 1. 使用非常繁琐,且需要处理各种数据库异常,并且还需要关闭各种资源。 2. 数据转化麻烦。查询之前需要从 Java 对象属性值设置到 PreparedStatement 中,查询返回之后又需要从 `ResultSet`获取返回设置到返回对象中。 在 ibatis 中封装这些繁杂数据库连接查询代码,并处理了各类异常以及关闭各种资源。另外 ibatis 自动处理 Java 对象与数据库类型之间的自动转化,让业务代码与 SQL

ibatis 核心原理解析!

北城以北 提交于 2019-11-26 12:03:41
关注下方公众号,可以在公众号后台回复“博客园”,免费获得作者 Java 知识体系/面试必看资料。 最近查找一个生产问题的原因,需要深入研究 ibatis 框架的源码。虽然最后证明问题的原因与 ibatis 无关,但是这个过程加深了对 ibatis 框架原理的理解。 这篇文章主要就来讲讲 ibatis 框架的原理。 可能现在很多人已不再使用 ibatis 或者说也没听 ibatis,不过肯定了解过 Mybatis。ibatis 就是 Mybatis框架的前身,虽然 ibatis 框架已经比较老,但是其核心功能与 Mybatis 一致。 ibatis 解决的痛点 我们先看一个使用 JDBC 查询的例子。 使用原生 JDBC 查询,存在两个痛点: 1. 使用非常繁琐,且需要处理各种数据库异常,并且还需要关闭各种资源。 2. 数据转化麻烦。查询之前需要从 Java 对象属性值设置到 PreparedStatement 中,查询返回之后又需要从 `ResultSet`获取返回设置到返回对象中。 在 ibatis 中封装这些繁杂数据库连接查询代码,并处理了各类异常以及关闭各种资源。另外 ibatis 自动处理 Java 对象与数据库类型之间的自动转化,让业务代码与 SQL 代码之间做到了解耦。 数据类型转化原理 数据类型转化主要分为两类,一,传入查询的 Java 对象数据转化成 SQL