=STR_TO_DATE(?,'%Y-%m-%d')",model.getXXX());_method th">
赞
踩
idea debug时sql报错:
Method threw 'java.util.UnknownFormatConversionException' exception. Cannot evaluate com.shangwei.koservice.web.DynamicSQL.toString()
原因:
sql.isNotNull(" and STR_TO_DATE(XXX,'%Y-%m-%d')>=STR_TO_DATE(?,'%Y-%m-%d')",model.getXXX());
用DynamicSQL拼接sql时,会对‘%’进行误判,误认为是占位符
应该 ‘%’ => ‘%%’
正确写法:
sql.isNotNull(" and STR_TO_DATE(XXX,'%%Y-%%m-%%d')>=STR_TO_DATE(?,'%%Y-%%m-%%d')",model.getXXX());
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。