Hibernate Criteria Restrictions用法


Date date = new Date();
        Criteria criteria = getSession().createCriteria(CustomerRegtn.class);
        criteria.add(Restrictions.eq("customer_no", customerNo));
        criteria.add(Restrictions.eq("status", status));
        criteria.add(Restrictions.and(
                Restrictions.le("startDate",DataUtils.date2Str(date, DataUtils.date_sdf)),
                Restrictions.ge("endDate",DataUtils.date2Str(date, DataUtils.date_sdf))));
        SmsCodeEntity smsCodeEntity = (SmsCodeEntity) criteria.uniqueResult();

你可能感兴趣的:(Hibernate,Criteria,Restrictions)