多条件查询2
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();
}
上一篇: 一、JavaScript 创建对象
下一篇: struts2 好令人伤心