ibatis

MyBatis/iBatis - reusable sql fragments in a separate SQL Map file?

丶灬走出姿态 提交于 2019-11-29 20:29:29
I would like to put sql fragments used by several of my SQL Map XML files in a separate file. At the moment, the <sql> elements with these fragments are in one of the mappers together with other elements like <select> , which makes them hard to find. Can I have a mapper that defines just a few <sql> elements and is not used to generate an implementation to an interface? What would be the correct namespace of this mapper? This is the SQL Map file with the framents: <mapper namespace="com.company.project.dao.someDao"> <sql id="whereDate"> WHERE date(`time`) BETWEEN #{startDate} AND #{endDate} <

ibatis.binding.BindingException Parameter '__frch_item_0' not found

前提是你 提交于 2019-11-29 19:15:32
nested exception is org.apache.ibatis.binding.BindingException 之前写代码的时候,想写一个批量的删除,我在mybatis层的xml中的sql是这样写的: <delete id="deleteByHpccIds" parameterType="List"> delete from pf_hpccdev_info where hpcc_id in <foreach collection="hpccIds" item="item" index="index" open="(" separator="," close=")"> #{item} </foreach> - </delete> 然后就报了下面的错误: Caused by: org.apache.ibatis.binding.BindingException: Parameter '__frch_item_0' not found. Available parameters are [oprInfo, hpccIds, param1, param2] at org.apache.ibatis.binding.MapperMethod$ParamMap.get(MapperMethod.java:202) at org.apache.ibatis.reflection

Maven项目环境搭建(Maven + Spring + IBatis)步骤

拥有回忆 提交于 2019-11-29 16:11:43
准备步骤 ‍ 1. 安装Maven, 下载解压即可。 官网下载 ‍ 2. 修改maven_home/conf/settings.xml中的<localRepository>D:/MavenRepo</localRepository>指定本地仓库位置,这个位置是本地计算机上用来存放所有jar包的地方。 ‍ 3. 修改settings.xml中的 ‍ <mirrors></mirrors>标签,添加常用的maven远程仓库地址。这些仓库地址就是用来下载jar包的时候用的。由于 中央仓库 的访问速度较慢(或者因为某些原因导致你根本不能访问),因此一般需要设置其他的仓库地址以提高访问速度。比如: <mirror> <id>oschina</id> <mirrorOf>central</mirrorOf> <url>http://maven.oschina.net/content/groups/public/</url> </mirror> <mirror> <id>repo2</id> <mirrorOf>central</mirrorOf> <url>http://repo2.maven.org/maven2/</url> </mirror> <mirror> <id>net-cn</id> <mirrorOf>central</mirrorOf> <url>http://maven

MyBatis parameter from HashMap

半腔热情 提交于 2019-11-29 16:02:46
In mapper interface I have: ArrayList<Item> select(@Param("filterId")int filterId, @Param("filterData")HashMap<String,Object> filterData); In mapper xml I have: <select id="select" parameterType="map" resultMap="RM"> SELECT ... FROM .... WHERE id=#{filterData["id"]} </select> No errors but the result is not as expected (it returns empty set but I know item with such id exists). The #{filterData["id"]} seems not to work. Where is my mistake? I found the answer: <select id="select" parameterType="map" resultMap="RM"> SELECT ... FROM .... WHERE id=#{filterData.id} </select> Rajesh If you have

How do I insert collection of objects using MyBatis 3.x?

久未见 提交于 2019-11-29 14:43:40
问题 I'm a beginner with MyBatis. I just want to know how to insert a collection of objects from an instance of a class. Say I have a class User related to a Note in one-to-many relationship. I just like to mention that I built my schema using JPA 2 annotations via Hibernate's hbm2ddl. I'll add the key JPA annotations I used in the sample code below. Here's a sample: @Entity public class User { ... @OneToMany @JoinColumn(name="user") public List<Note> getNotes() {...} ... } Now, everytime I insert

记录下之前所总结的spirngmvc数据库的一些杂乱知识点

佐手、 提交于 2019-11-29 14:17:52
(!!在springmvc控制器层,查询到的学生信息可以直接用return student;此时在前端jquery中的回调函数function(result){}中的result就是控制器层的那个学生数据可以通过遍历取出来,如果是ruturn "student"则是返回一个页面,但记得此时必须在方法上加上@requestbody表示返回一个json字符串)!! 向上转型目的:这是为了面向接口编程,多态化而设计的 @modelattrobite注解表示在程序执行时,最先执行这个注解的方法 A。在controller控制器中每个方法的前面需要加上RequestMapping(); eg:RequestMapping("index") pulib ModelAndView index(){ ModelAndView mv=new ModelAndView("success"); return mv } (redirect:/index)含义就是通过控制器重定向定位到index这里,再进入success.jsp页面中 当输入localhost:8080/ssm/XXX XXX的含义就是你controller控制器里方法前的那个RequestMapping("XXX")的XXX,由此进入,再通过ModelAndView mv=new ModelAndView("success")

MySql.Data.MySqlClient.MySqlException: Timeout expired

会有一股神秘感。 提交于 2019-11-29 13:12:51
In recent times, a particular page in my web app throws the Exception Details: MySql.Data.MySqlClient.MySqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Though I use Ibtais as persistence layer, this error occurs. I have restarted the MySql service instance but stil i get the same error. It didn't happen earlier but happens frequently in recent times. All the web applications deployed on the server uses Ibatis and the DB server remains on the same machine where IIS is installed. There are about 8000 records in which

Iterate list of Objects in Ibatis

血红的双手。 提交于 2019-11-29 10:28:26
问题 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? 回答1: 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="("

org.apache.ibatis.reflection.ReflectionException: There is no getter for property named &apos;id&apos;

回眸只為那壹抹淺笑 提交于 2019-11-29 10:18:31
如果只有一个参数可以这样用 : 使用内置的 mybatis 提供的参数 _parameter AND o.parent_ids LIKE '%,${_parameter},%' ,否则多个还是需要使用 mybatis 的 @param 来标识 参数名的 来源: https://my.oschina.net/ouminzy/blog/3105639

MyBatis日志模块分析

非 Y 不嫁゛ 提交于 2019-11-29 08:53:52
MyBatis日志模块分析 标签(空格分隔): 未分类 日志功能代码所在包 org.apache.ibatis.logging 日志模块的加载顺序 mybatis 没有自己的日志模块 他是使用的第三方日志(也有jdk自带日志) 日志的加载顺序 slf4J → commonsLoging → Log4J2 → Log4J → JdkLog 相关代码 在静态代码块儿中声明加载顺序 public final class LogFactory { //被选定的第三方日志组件适配器的构造方法 private static Constructor<? extends Log> logConstructor; /** * Marker to be used by logging implementations that support markers */ public static final String MARKER = "MYBATIS"; //被选定的第三方日志组件适配器的构造方法 private static Constructor<? extends Log> logConstructor; //自动扫描日志实现,并且第三方日志插件加载优先级如下:slf4J → commonsLoging → Log4J2 → Log4J → JdkLog static {