`

多条件查询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();

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics