[color=red]这是User.xml中Sql语句[/color]
<mapped-statement name="getUserNumByIdAndCreatetime" result-class="java.lang.Integer">
<![CDATA[
select count(*) as sum
from user
where id = #value# and createtime like '%$value1$%'
]]>
</mapped-statement>
[color=darkred]这是UserDao.java中的方法[/color]
public int getUserNumByIdAndCreatetime(int id,String createtime) throws DaoException,NumberFormatException, SQLException{
Map map = new HashMap();
map.put("id", new Integer(id));
map.put("createtime", new String(createtime));
return Integer.parseInt(SqlMapConfig.getSqlMap().executeQueryForObject("getUserNumByIdAndCreatetime",map).toString());
}
经过以上两步应该可以实现模糊查询,为什么我得不到结果呢?
还有User.xml中,当我单独用like时可以查询到结果,可是再加上and id = #value#就得不到结果了,也不报错!!很是郁闷呀!
究竟是哪里出了错误?那位仁兄给解决一下?小弟在这里感谢了!!急呀!!
<mapped-statement name="getUserNumByIdAndCreatetime" result-class="java.lang.Integer">
<![CDATA[
select count(*) as sum
from user
where id = #value# and createtime like '%$value1$%'
]]>
</mapped-statement>
[color=darkred]这是UserDao.java中的方法[/color]
public int getUserNumByIdAndCreatetime(int id,String createtime) throws DaoException,NumberFormatException, SQLException{
Map map = new HashMap();
map.put("id", new Integer(id));
map.put("createtime", new String(createtime));
return Integer.parseInt(SqlMapConfig.getSqlMap().executeQueryForObject("getUserNumByIdAndCreatetime",map).toString());
}
经过以上两步应该可以实现模糊查询,为什么我得不到结果呢?
还有User.xml中,当我单独用like时可以查询到结果,可是再加上and id = #value#就得不到结果了,也不报错!!很是郁闷呀!
究竟是哪里出了错误?那位仁兄给解决一下?小弟在这里感谢了!!急呀!!