- 浏览: 199639 次
- 性别:
- 来自: 哈尔滨
文章分类
- 全部博客 (267)
- java.lang (8)
- 问题汇总 (21)
- 异常记录 (20)
- 功能实现 (19)
- 面试总结 (25)
- 技巧总结 (8)
- 常用代码 (4)
- 编程习惯 (3)
- 编码规则 (3)
- java.util (10)
- java.io (1)
- JavaWeb (9)
- MySQL (16)
- SVN (3)
- MyBatis (11)
- Velocity (7)
- 其他知识 (10)
- 人生哲理 (1)
- 人生故事 (1)
- 自我感悟 (1)
- shiro (3)
- 基础知识 (0)
- 问题总结 (1)
- Spring 标签 (1)
- Spring (3)
- 点滴生活 (1)
- DOS (1)
- CAS (4)
- Linux (9)
- Storm (6)
- Shell (1)
- regex (1)
- Collection (4)
- poi (1)
- 经典语句 (1)
- NIO (5)
- concurrent (14)
- RPC (1)
- zookeeper (3)
- 待整理 (2)
- Hadoop (9)
- RabbitMq (2)
- flume (1)
- hive (7)
- hbase (4)
- kafka (1)
- scala (1)
- GC (0)
- java.util.concurrent.atomic (1)
- java.lang.ref (6)
- JVM (2)
- algorithm (1)
- conception (1)
- java key word (1)
- sun.misc (1)
最新评论
报错原因:
1.用mybatis查询时,传入一个字符串传参数,且进行判断时,会报异常
2.mapper.xml 中id值有重复的(出现原因:拷贝上面的实现,修改下参数或SQL,忘记ID值唯一的修改了)
1.错误写法:
需要修改成:
总结:不管你的参数是什么,都要改成"_parameter"
原文地址:http://txin0814.iteye.com/blog/1533645
参考文献:http://blog.csdn.net/noku_ln10/article/details/7977976
2.改写parameter_type为 map
接口:
Mapper.xml
注意:
1.parameterType="java.util.Map" Map为大写,若写成map会报错
2.或直接写成map
调用:
3.若封装在工具类中需要引用
注意:
merchantid = #{parameter.merchantid,jdbcType=VARCHAR},若为
merchantid = #{merchantid,jdbcType=VARCHAR},就会出现上面的错误
1.用mybatis查询时,传入一个字符串传参数,且进行判断时,会报异常
2.mapper.xml 中id值有重复的(出现原因:拷贝上面的实现,修改下参数或SQL,忘记ID值唯一的修改了)
There is no getter for property named 'moduleCode' in 'class java.lang.String
1.错误写法:
<select id="queryAllParentModule" resultType="jobModule" prameterType="jobModule"> select modulecode,modulename,modulevalue,linkurl,rank, parentmodule=isnull(parentmodule,1),moduledescription from job_module <where> <choose> <when test="moduleCode!=null and moduleCode!=''">modulecode = #{moduleCode} </when> </choose> </where> </select>
需要修改成:
<select id="queryModuleByCode" resultType="jobModule" parameterType="string"> select modulecode, modulename,modulevalue,linkurl, rank,parentmodule=isnull(parentmodule,1),moduledescription from job_module <where> <choose> <when test="_parameter!=null and _parameter!=''">modulecode = #{_parameter}</when> </choose> </where> </select>
总结:不管你的参数是什么,都要改成"_parameter"
原文地址:http://txin0814.iteye.com/blog/1533645
参考文献:http://blog.csdn.net/noku_ln10/article/details/7977976
2.改写parameter_type为 map
接口:
public List<Long> viewUidsLikeName(Map<String, Object> params);
Mapper.xml
<select id="viewUidsLikeName" resultType="java.lang.Long" parameterType="java.util.Map"> SELECT id FROM usr_users where 1=1 <if test="username != null"> and username like concat ('%','${username}','%') </if> <if test="email != null"> and email like concat ('%','${email}','%') </if> </select>
注意:
1.parameterType="java.util.Map" Map为大写,若写成map会报错
2.或直接写成map
调用:
public List<Long> selectUidsByUsername(String username) { if(StringUtil.isBlank(username)){ return null ; } Map<String, Object> params = new HashMap<String, Object>(); if(UserUtils.isEmailAdress(username)){ params.put("email", username); }else{ params.put("username", username); } return userMapper.viewUidsLikeName(params); }
3.若封装在工具类中需要引用
<select id="selectscheduleTrackingsListPage" resultMap="BaseResultMap" parameterType="mybatis.utility.PageBean"> SELECT <include refid="Base_Column_List" /> from usr_merchant_schedule_tracking where 1 = 1 <if test="parameter.startTime != null and parameter.startTime !=''"> and date_format(create_time,'%Y-%m-%d') >= date_format(#{parameter.startTime},'%Y-%m-%d') </if> <if test="parameter.endTime != null and parameter.endTime !=''"> <![CDATA[ and date_format(create_time,'%Y-%m-%d') <= date_format(#{parameter.endTime},'%Y-%m-%d') ]]> </if> <if test="parameter.merchantid != null and parameter.merchantid !=''"> and merchantid = #{parameter.merchantid,jdbcType=VARCHAR} </if> </select>
注意:
merchantid = #{parameter.merchantid,jdbcType=VARCHAR},若为
merchantid = #{merchantid,jdbcType=VARCHAR},就会出现上面的错误
发表评论
-
can not find xxx.xxx
2017-10-03 10:20 372问题描述: 单元测试一个已离职同事的接口,运行时提示 po ... -
为什么运行接口无返回值
2017-10-02 18:08 738问题场景: 与同事共同开发一个项目,调用其开发的接口,未接收 ... -
xxxList not found
2015-05-20 08:51 636问题:MyBatis接口中以list作为参数类型,在mappe ... -
Result Maps collection already contains value for mapper.XXX
2015-05-14 08:53 2087问题:运行单元测试类时报错 原因:应该用resultMap来 ... -
常用mapper方法
2015-05-11 19:49 6491.insert,表中有时间字段,且字段值为当前时间,可以在m ... -
确认方法没有错误,但查询结果不正确
2015-05-07 09:37 819问题:在调试某web工程时,发现一个po.getXXX()没有 ... -
语法错误,查询条件中带有多余的单引号
2015-05-07 09:27 687场景:列表检索功能,查询条件中带有英文单引号,点击查询,系统异 ... -
MyBatis的动态SQL详解
2015-04-29 19:21 635[size=medium]MyBatis的动态SQL是基于OG ... -
MyBatis中resultType和resultMap的区别
2015-04-29 15:28 3820[size=medium][align=left] MyBat ... -
mybatis中的#和$的区别?
2015-04-27 09:24 5451. #将传入的数据都当成一个字符串,会对自动传入的数据加 ...
相关推荐
今天小编就为大家分享一篇关于Mybatis单个参数的if判断报异常There is no getter for property named 'xxx' in 'class java.lang.Integer'的解决方案,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,...
解决Mybatis 分页插件pagehelper不支持逆向工程Example条件查询.含源码和jar包
String.class,String[].class, BigDecimal.class,BigDecimal[].class, BigInteger.class,BigInteger[].class, Date.class,Date[].class 通过对以上基本元数据类型的模拟实现,本框架可以轻松模拟由以上元...
主要介绍了使用Mybatis遇到的there is no getter异常,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
常问问题1,出现了如下BUG org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'statement' in 'class ...
主要给大家介绍了mybatis中foreach报错:_frch_item_0 not found的解决方法,文章通过示例代码介绍了详细的解决方法,对大家具有一定的参考学习价值,需要的朋友们下面来一起看看吧。
<property name="deptname" type="java.lang.String"> </property> <property name="deptnum" type="java.lang.Integer"> </property> <property name="actNum" type="java.lang.Integer"> </property> ...
However, there are some occasions where dynamic access to Java object properties (without compiled-in knowledge of the property getter and setter methods to be called) is needed. Example use cases ...
The Person class should have a setter method and a getter method with public access for each attribute. In the setter methods, get rid of any leading or trailing spaces (String trim() method). For...
这是Nicolas Ricquemaque的Ogg.class.php的继续,而后者又是David Grant的File_Ogg的一部分(您不喜欢自由软件吗?)。 最初,该项目仅会修复错误,并对Ogg.class.php代码进行较小的调整,在没有声明的情况下不会...
Available options (for this frontend in Zend_Cache factory) 4.3.6.3. Examples 4.4. Zend_Cache后端 4.4.1. Zend_Cache_Backend_File 4.4.2. Zend_Cache_Backend_Sqlite 4.4.3. Zend_Cache_Backend_...
java 的eclipse或idea等 定义变量时 直接引入lombok.jar包 在类外部 引入@AllArgsConstructor @NoArgsConstructor @Data 简便方法引入getter/setter/tostring等方法
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'URIType' of bean class [com.alibaba.citrus.service.uribroker.uri.GenericURIBroker]: Bean property 'URIType' is not ...
public final StringProperty Name ; /* * Age of person. */ public final IntegerProperty Age ; public TestBean () { // this.Name = add(new StringProperty("Name")); this . Name = add
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController' defined in ServletContext resource [/WEB-INF/springMVC-servlet.xml]: Error ...
"fullscreen=no,channelmode=no,toolbar=no,location=no,menubar=no,scrollbas=no,resizable=no," 20.状態栏的设置:window.status="字符"; 21.弹出提示信息:window.alert("字符"); 22.弹出確认框:window.confirm(); ...
7. <id name="fileId" type="java.lang.String" column="FILE_ID"> 8. <generator class="uuid.hex"/> 9. 10. <property name="fileContent" 11. type="org.springframework.orm.hibernate3.support....
public class PenBean { /**类型*/ private String type; /**颜色*/ private String color; //... 省略 setter 和 getter public PenBean(String type, String color) { this.type = type; this.color =...
实验代码: public class StrPro { public static void main(String[] args) { String str[] = new String[5]; System.out.println("Please input 10 strings:"); int i; String max,min; for(i=0;i;i++){ System....