多条件查询2
程序员文章站
2022-03-08 08:33:49
...
protected String generateBaseHql(String model, String[] propertyName, String[] value, String[] propertyLikeName,
String[] likeValue,List addedValues)
{
StringBuffer baseHql = new StringBuffer();
baseHql.append("from" + model + "as model where 1=1 ");
/**
* 处理常规值
*/
for (int i = 0; i < propertyName.length; i++)
{
if (!Converter.isEmptyString(value[i]))
{
baseHql.append("and " + "model." + propertyName[i] + "=?");
addedValues.add(value[i]);
}
}
/**
* 处理模糊匹配
*/
for (int i = 0; i < propertyLikeName.length; i++)
{
if (!Converter.isEmptyString(likeValue[i]))
{
baseHql.append("and " + "model." + propertyLikeName[i] + "like ?");
addedValues.add(likeValue[i]);
}
}
return baseHql.toString();
}
上一篇: php中两个数组怎么去掉重复的元素