ibatis

操作ibatis,struts,spring的整合

☆樱花仙子☆ 提交于 2019-11-30 09:22:27
处理 mybatis ,struts,spring框架的整合作为学习 java资料 步骤: 一 . 添加 Spring 、 Struts 框架对 web .xml 文件的修改 1. 添加 Spring 框架 2. 在 web.xml 中引入 Spring 配置文件(注意: applicationContext.xml 文件的路径) < context-param > < param-name > contextConfigLocation </ param-name > < param-value > /WEB-INF/conf/applicationContext.xml </ param-value > </ context-param > < servlet > < servlet-name > context </ servlet-name > < servlet-class > org.springframework.web.context.ContextLoaderServlet </ servlet-class > < load-on-startup > 1 </ load-on-startup > </ servlet > 3. 添加 Struts 框架 4. 在 web.xml 中引入 Spring 配置文件(注意: struts-config.xml 文件的路径

Iterate list of Objects in Ibatis

半城伤御伤魂 提交于 2019-11-30 07:25:29
I have a list of object where I want to iterate and access a particular field in ibatis sql. Ex. public Class Student { String id; String name; } I will pass as parameter a List of Student object(List(Student)) and do iteration accessing the id for each object bean. How do I do this? The foreach -tag is what you are looking for. Example: <select id="selectPostIn" resultType="domain.blog.Post"> SELECT * FROM POST P WHERE ID in <foreach item="item" index="index" collection="list" open="(" separator="," close=")"> #{item} </foreach> </select> See the user guide for more info, chapter "dynamic sql

我为什么不用hibernate而用ibatis

和自甴很熟 提交于 2019-11-30 07:19:20
入行前几年,一味追求框架SSH,使用并潜心研究。随着阅历和能力的增加,对系统的把控欲越来越强,近年已经甚少用Hibernate(也指JPA),我总结为以下几点原因: 1、Hibernate学习曲线陡峭、时间长。新手从入门到熟悉需要经历几个项目,少则几个月多则一两年。在项目开发周期越来越短,发布越来越频繁的现在,略显漫长,自己也没那个精力和心思去教。 2、Hibernate封装严密,好处是大家写起来都一样,但限制了可控性。我听到DBA跟我说:他喜欢ibatis,因为你们把sql写在xml里他能看到。 3、SQL敢称为language自然有其存在的价值和道理,计算机专业毕业生理论上都已掌握,这种群众基础咱不能浪费。 4、有项目需要DBA根据需要配置sql,没门,提需求程序员改,要不您也能去调Java代码。 没用Hibernate,我所接触的项目也没需要用纯JDBC来寻求性能,所以原来只做查询的ibatis入了咱的法眼。同时引用了spring-data-commons-core里的Pageable接口和PageRequest实现类、Page和PageImpl实现类,免得自己再写分页相关的代码。用spring-orm的SqlMapClientTemplate免得自己写模板代码。 来源: oschina 链接: https://my.oschina.net/u/76091/blog

Tasklet to delete a table in spring batch

给你一囗甜甜゛ 提交于 2019-11-30 06:04:04
问题 I have steps in the batch job that does different things. But before I begin all these steps, I need to clear a table. Is there any simple way to write a tasklet that will delete the table directly from the job xml file ? I am using ibatis as ORM 回答1: you mean even more simple than a tasklet, e.g. like this pseudocode ? <!-- xml bean config --> <bean id="deleteTableTaskletStep" class="..."> <property name="dataSource" ref="dataSource" /> <property name="sql" value="delete from ..." /> </bean>

Would you use NHibernate for a project with a legacy database, which is partly out of your control?

ε祈祈猫儿з 提交于 2019-11-30 05:42:19
问题 For me the answer is currently: No, I would use iBatis, because NHibernate is a pain, when the database model and the object model are not in synch. If I don't have full control over the database I end up with a lot of work. Why do I ask? Well, first of all: I never used NHibernate. I just know it from the surface. I have read about the advantages of iBatis for legacy databases. Second: Recently I had a discussion with someone who worked with Hibernate (jep, without 'N' before Hibernate). He

iBatis, spring, how to log the sql that is executed?

感情迁移 提交于 2019-11-30 04:49:41
I am using iBatis with spring framework. I want to log the sql that iBatis executes when I say something like Employee e = (Employee) getSqlMapClientTemplate().queryForObject("emp_sql", emp); The above line will look for "emp_sql" id in the ibatis sql file that I have. And then run the query corresponding to "emp_sql". I want to log this query. I have the following log4j xml properties file. <appender name="sqlLogAppender" class="org.apache.log4j.DailyRollingFileAppender"> <param name="file" value="/disk1/logs/sql.log"/> <param name="datePattern" value="'-'yyyy-MM-dd'.txt'"/> <layout class=

【转】我为什么选择 iBatis 而不是 Hibernate(对于正在选型的人的建议)

£可爱£侵袭症+ 提交于 2019-11-30 02:02:13
我在最初的选型的时候是打算选择 Hibernate 的,在研究的过程中发现了 iBatis,经过 分析比较之后我选择了 iBatis。现在我已经使用 iBatis 完成了一个中小型的项目。这个 项目在性能、可维护性、可扩展性方面都非常令我满意。 在这个过程中我也不断的与使用过或者正在使用 Hibernate 的人进行过探讨。而且我本身 也在不断的跟进 Hibernate 的发展。 最终,我的结论是 iBatis 的选择非常正确,而且越用越喜欢它了。 当然了,我对 Hibernate 的理解还是非常有限的,所以这里的关于 Hibernate 的一些观 点的错误之处希望能够得到 Hibernate 高手的指正。 1. iBatis 易于掌握。拿来文档看半天到两天就可以掌握了。 Hibernate 可能需要 3 倍以上的时间来掌握。 2. iBatis 更容易进行 sql 的 优化。 这个应该大家都有共识了。另外 Hibernate 生成的 sql 也实在是太难看了。鉴 于有的朋友提到了 sql 不太重要。我想在这里强调一下我的经验,一般系统性能 的 瓶颈都在数据库 上。所以这一点是 iBatis 非常重要的一个优势。 3. iBatis 可以进行细粒度的优化 3.1 比如说我有一个表, 这个表有几个或者几十个字段 ,我需要更新其中 的一个字段,iBatis 很简单,执行一个sql

org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.sql.SQ

可紊 提交于 2019-11-29 23:58:05
org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.sql.SQLException: No suitable driver found for jdbc.mysql://localhost:3309/test ### The error may exist in mapper/User.xml ### The error may involve com.findById ### The error occurred while executing a query ### Cause: java.sql.SQLException: No suitable driver found for jdbc.mysql://localhost:3309/test at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:122) at org.apache

Ibatis中的动态SQL:isNotNull,isPropertyAvailable,isNotEmpty用法

谁说我不能喝 提交于 2019-11-29 22:44:00
[size=large]常用的几个关键字和属性: isNotNull 参数不为null时有效 sNotEmpty 参数不为null或“”时有效 isPropertyAvailable 如果参数有使用则查询条件有效 prepend <isNotNull prepend="and" property="firstName" > 生成的语句不会有多余的and,因为dynamic有一个隐藏的属性:removeFirstPrepend="true", 所以一般要写上prepend="and",需要的时候它会自动去掉。 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Ibatis中的动态SQL,主要分为一元条件和二元条件查询: 一元条件查询关键字: <isPropertyAvailable> 如果参数有使用则查询条件有效。 <isNotPropertyAvailable> 如果参数没有使用则查询条件有效。 <isNull> 如果参数为NULL则查询条件有效。 <isNotNull> 如果参数不为NULL则查询条件有效。 <isEmpty> 如果参数为空则查询条件有效。 <isNotEmpty> 如果参数不为空则查询条件有效。参数的数据类型为Collection String 时参数不为NULL或“”