我的代码有问题。如果我输入正确的标准,假设它返回正确结果/秒的数量为 300。但如果我输入不合格的搜索标准,它仍然返回不正确的结果/秒。
@Override
public Page<ApPayment> searchPayment(final String searchCriteria,
final PageSetting pageSetting) {
HibernateCallback<Page<ApPayment>> paymentCallBack = new HibernateCallback<Page<ApPayment>>() {
@Override
public Page<ApPayment> doInHibernate(Session session)
throws HibernateException, SQLException {
Criteria criteria = session.createCriteria(ApPayment.class);
if(!searchCriteria.isEmpty() && StringFormatUtil.isNumeric(searchCriteria)) {
Integer paymentNo = Integer.valueOf(searchCriteria);
Double amount = Double.valueOf(searchCriteria);
criteria.add(Restrictions.or(Restrictions.like(ApPayment.FIELD.paymentNumber.name(), paymentNo), Restrictions.eq(ApPayment.FIELD.amount.name(), amount)));
}
Page<ApPayment> payments = getAll(criteria, pageSetting);
for (ApPayment payment: payments.getData()) {
--some codes--
}
return payments;
}
};
return getHibernateTemplate().execute(paymentCallBack);
}
提前致谢。