ibatis

Spring MVC 学习总结(十)——Spring+Spring MVC+MyBatis框架集成(IntelliJ IDEA SSM集成)

青春壹個敷衍的年華 提交于 2019-12-21 06:46:41
Spring MVC 学习总结(十)——Spring+Spring MVC+MyBatis框架集成(IntelliJ IDEA SSM集成) 目录 一、新建一个基于Maven的Web项目 1.5、Idea整合Tomcat 1.6、将依赖包添加到Web-Inf目录下 二、创建数据库与表 三、添加依赖包 四、新建POJO实体层 五、新建MyBatis SQL映射层 六、JUnit测试数据访问(非必要) 七、完成Spring整合MyBatis配置 八、配置web.xml加载Spring容器与MVC 九、创建服务层 十、完成图书管理功能 10.1、图书列表 11.2、删除与多删除功能 11.3、新增图书功能 11.4、编辑图书功能 11.5、日志、首页、样式与最终的控制器 十二、总结与问题 十三、示例下载与预览 与SSH(Struts/Spring/Hibernate/)一样,Spring+SpringMVC+MyBatis也有一个简称SSM,Spring实现业务对象管理,Spring MVC负责请求的转发和视图管理, MyBatis作为数据对象持久化引擎。这样搭配的优点是:轻量、自由度高、Spring与Spring MVC契合度更好。通过一个图书管理示例完成SSM框架的集成,可以将前面学习过的一些内容整合起来,使用到的知识包含:Spring、Spring MVC、MyBatis

Spring MVC 学习总结(十)——Spring+Spring MVC+MyBatis框架集成(IntelliJ IDEA SSM集成)

旧巷老猫 提交于 2019-12-21 04:40:21
与SSH(Struts/Spring/Hibernate/)一样,Spring+SpringMVC+MyBatis也有一个简称SSM,Spring实现业务对象管理,Spring MVC负责请求的转发和视图管理, MyBatis作为数据对象持久化引擎。这样搭配的优点是:轻量、自由度高、Spring与Spring MVC契合度更好。通过一个图书管理示例完成SSM框架的集成,可以将前面学习过的一些内容整合起来,使用到的知识包含:Spring、Spring MVC、MyBatis、JSR303校验、分页、文件上传、路径处理等。 说明:本文只是为了讲解SSM在IDEA中的集成方法,如果您想了解更加详细的内容,请参考本人的另一篇博客内容: Spring MVC 学习总结(六)——Spring+Spring MVC+MyBatis框架集成 一、新建一个基于Maven的Web项目 1.1、创建一个简单的项目,这里不使用模板。如下图所示: 1.2、填写好包名、项目名如下图所示: 1.3、将项目转换成web项目 转换成功: 1.4、项目创建好后添加依赖包,方法有两种,一种直接使用maven,一种手动添加。 使用maven: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0"

mybatis: Using mapper interfaces with XML config for global parameters

徘徊边缘 提交于 2019-12-20 10:37:14
问题 I like the XML notation for specifying global parameters such as connection strings. I also like Mapper annotations. When I try to combine the two, I get this exception. Is there a way to combine the two? I would like to use an XML file for the global configurations, but have mybatis take Mapper interfaces into account. The problem is that SqlSessionFactoryBuilder().build() takes either a Reader (which I want to use to pass the XML config), or a Configuration object (which I see has the

Oracle - connection Pooling with spring framework

拈花ヽ惹草 提交于 2019-12-20 09:25:23
问题 We are trying to implement Oracle connection pooling with the help of Spring Framework. We are using DBCP connection pooling method. However the integration between DBCP and spring doesn't go down that well. Problem that we face is that DBCP returns PoolableConnections Object while Oracle expects OracleConnection Objects. (Throws ClassCastException) It seems that this problem has been handled in Oracle 11g. However I am curious as to how others have implemented Oracle connection pooling using

How to Return NULL-values in iBatis?

纵饮孤独 提交于 2019-12-20 05:19:26
问题 Let's say I have an Oracle database and an interface like this: public interface DaoMapper { @Select({ "SELECT col1, col2, col3", "FROM my_table" }) List<Map<String, Object>> getUntyped(); } If I call getUntyped() and all columns have a value the map contains three entries. However, if col2 is NULL , the map has only two entries. In many cases this isn't a problem, but in a generic part of our code I actually want to call .values() on that map and want a list consisting of three entries. Any

Fetching a LONGBLOB as a byte array using MyBatis

给你一囗甜甜゛ 提交于 2019-12-19 04:04:54
问题 I am using MyBatis in a project, where I have a query that gets data from a LONGBLOB field in a MySQL database. I wish to get the result as a byte array ( byte[] ), so I try this: <select id="fetchData" resultType="_byte[]" parameterType="_long"> select blobData from Table where id = #{id} </select> This does not work, however. I get the following error: java.lang.ClassCastException: [B cannot be cast to [Ljava.lang.Object; at org.apache.ibatis.binding.MapperMethod.convertToArray(MapperMethod

MyBatis - how to create w dynamic WHERE Clause

本秂侑毒 提交于 2019-12-18 13:35:55
问题 The service gets an unknown object containing a list of three values ​​[column, operator, value] For example, EMAIL - like - "TEST" Based on the resulting list to build the WHERE clause I have but I would also be able to build such a condition as follows (for example) WHERE (email like 'test' AND user_id <> 5) OR (trans_id <100 AND session_id> 500) Does anyone can help me how to do it? 回答1: I have been rediscovering MyBatis after a long absence myself (I was familiar with iBatis at one time).

Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for …

我是研究僧i 提交于 2019-12-18 12:39:24
编译通过并且运行web成功后,访问的页面不需要连接数据库,不牵扯到反射调用实体类就不会报错, 报错内容如下: [WARNING] org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.erp.sys.dao.table.mapper.SysUserPOMapper.selectByExample ### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.erp.sys.dao.table.mapper

org.apache.ibatis.binding.BindingException

左心房为你撑大大i 提交于 2019-12-18 06:08:35
org.apache.ibatis.binding.BindingException: Parameter 'name' not found. Available parameters are [device, param1] at org.apache.ibatis.binding.MapperMethod$ParamMap.get(MapperMethod.java:204) at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:115) at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:2685) at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:114) at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212) at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258) at org

Difference between ibatis and mybatis

一笑奈何 提交于 2019-12-17 22:36:54
问题 What is the difference between iBatis and myBatis? Where can i find a perfect example of those ? Please suggest. I went through Google and could not find any links for this question. 回答1: MyBatis is a fork from iBATIS, and according to Wikipedia most of iBATIS' developers moved over to MyBatis too. The iBATIS project is currently marked as Inactive, therefore you should go with MyBatis for new projects and only use iBATIS if you're maintaining an existing project which already uses iBATIS.