首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

hibernate中integer门类模糊查询的技巧

2012-11-01 
hibernate中integer类型模糊查询的技巧把integer类型映射成string类型,利用like对字符串的hql模糊查询。比

hibernate中integer类型模糊查询的技巧
把integer类型映射成string类型,利用like对字符串的hql模糊查询。

比如对vo中定义的integer主键进行模糊查询:
<id
            name="estId"
            column="EST_ID"
            type="java.lang.Integer"
        >
<generator and a.strId like:estId" );
countSql.append( " and a.strId like:estId" );
pars.put( "estId", '%'+ model.getEstName()+'%');

附注:java中判断输入文字是数字的方法:
Pattern pattern = Pattern.compile("[0-9]*");
if(pattern.matcher(model.getEstName()).matches())
{
   满足条件……
}

热点排行