StringBuilder hql = new StringBuilder();
if (mailboxRC.getSrcIp() != 0)
hql.append("and mail.srcIp=:srcIp");
if (mailboxRC.getDstIp() != 0)
hql.append(" and mail.dstIp=:dstIp");
if (mailboxRC.getTimeCriterion() != null) {
// 使用原始时间
if (mailboxRC.getTimeCriterion().equalsIgnoreCase("original")) {
hql.append(" and mail.time>:lastRetrieveTime");
} else // 从上次检索至今
{
hql.append(" and mail.time>:startTime");
}
hql.append(" and mail.time<:endTime");
}
if (mailboxRC.getSender() != null
&& mailboxRC.getSender().trim().length() != 0) {
//hql.append(" and mail.mailFrom=:sender");
hql.append(" and mail.mailFrom like '%'+'"+":sender"+"'+'%'");
}
like查询那里要如何放置一个变量不懂呀