Java 类org.hibernate.criterion.MatchMode 实例源码

项目:unitimes    文件:Staff.java   
/**
 * Search staff list for instructors with matching names
 * @param fname First Name 
 * @param lname Last Name
 * @return
 */
public static List findMatchingName(String fname, String lname) {
    List list = null;

    if ( (fname==null || fname.trim().length()==0) 
            && (lname==null || lname.trim().length()==0) )
        return list;

    Conjunction and = Restrictions.conjunction();
    if (fname!=null && fname.trim().length()>0)
        and.add(Restrictions.ilike("firstName", fname, MatchMode.START));
    if (lname!=null && lname.trim().length()>0)
        and.add(Restrictions.ilike("lastName", lname, MatchMode.START));

    StaffDAO sdao = new StaffDAO();
    list = sdao.getSession()
                .createCriteria(Staff.class)    
                .add(and)   
                .list();

    Collections.sort(list);

    return list;
}
项目:NewsSystem    文件:NewsInfoDAOImpl.java   
/**
 * 根据条件查询指定新闻
 */
@Override
public List<?> getNewsInfoByConditionAndPage(NewsInfo condition, int page, int pageSize) {
    Session session = SessionFactory.getCurrentSession();
    Criteria criteria = session.createCriteria(NewsInfo.class);
    if (condition != null) {
        if (condition.getTopic() != null && condition.getTopic().getId() != null ) {
            criteria.add(Restrictions.eq("topic.id", condition.getTopic().getId()));
        }
        if (condition.getTitle() != null && !"".equals(condition.getTitle())) {
            criteria.add(Restrictions.like("title", condition.getTitle(), MatchMode.ANYWHERE));
        }
    }
    criteria.setFirstResult(pageSize * (page - 1));
    criteria.setMaxResults(pageSize);
    criteria.addOrder(Order.desc("createDate"));
    return criteria.list();
}
项目:OSWf-OSWorkflow-fork    文件:HibernatePersistentVarsDAO.java   
@SuppressWarnings("unchecked")
protected Collection<String> getKeysImpl(Session session, Long piid, String prefix, Type type) throws HibernateException {

    if( piid == null )
        return Collections.EMPTY_LIST;

    Criteria criteria = session.createCriteria(getPersistentClass())
        .add(Restrictions.eq("processInstanceId", piid))
        .setProjection(Projections.property("key"));

    if (prefix != null)
        criteria.add(Restrictions.ilike("key", prefix, MatchMode.START));

    if(type != null)
        criteria.add(Restrictions.eq("type", type.getValue()));

    return criteria.list();
}
项目:gitplex-mit    文件:CommentInput.java   
@Override
protected PullRequestReferenceSupport getPullRequestReferenceSupport() {
    return new PullRequestReferenceSupport() {

        @Override
        public List<PullRequest> findRequests(String query, int count) {
            EntityCriteria<PullRequest> criteria = EntityCriteria.of(PullRequest.class);
            criteria.add(Restrictions.eq("targetProject", getProject()));
            if (StringUtils.isNotBlank(query)) {
                query = StringUtils.deleteWhitespace(query);
                criteria.add(Restrictions.or(
                        Restrictions.ilike("noSpaceTitle", query, MatchMode.ANYWHERE), 
                        Restrictions.ilike("numberStr", query, MatchMode.START)));
            }
            criteria.addOrder(Order.desc("number"));
            return GitPlex.getInstance(Dao.class).findRange(criteria, 0, count);
        }

    };
}
项目:sctalk    文件:JpaRestrictions.java   
/**
 * 模糊匹配
 * 
 * @param fieldName 字段名
 * @param value 字段值
 * @param matchMode 匹配类型
 * @param ignoreNull 是否忽然空值
 * @return 条件表达式
 * @return
 */
public static SimpleExpression like(String fieldName, String value, MatchMode matchMode, boolean ignoreNull) {
    if (StringUtils.isEmpty(value))
        return null;
    SimpleExpression expression;
    switch (matchMode) {
        case START:
            expression = new SimpleExpression(fieldName, value, Operator.LLIKE);
            break;
        case END:
            expression = new SimpleExpression(fieldName, value, Operator.RLIKE);
            break;
        case ANYWHERE:
            expression = new SimpleExpression(fieldName, value, Operator.LIKE);
            break;
        default:
            expression = new SimpleExpression(fieldName, value, Operator.LIKE);
            break;
    }

    return expression;
}
项目:DWSurvey    文件:HibernateDao.java   
/**
 * 按属性条件参数创建Criterion,辅助函数.
 */
protected Criterion buildCriterion(final String propertyName, final Object propertyValue, final MatchType matchType) {
    AssertUtils.hasText(propertyName, "propertyName不能为空");
    Criterion criterion = null;
    //根据MatchType构造criterion
    switch (matchType) {
    case EQ:
        criterion = Restrictions.eq(propertyName, propertyValue);
        break;
    case LIKE:
        criterion = Restrictions.like(propertyName, (String) propertyValue, MatchMode.ANYWHERE);
        break;

    case LE:
        criterion = Restrictions.le(propertyName, propertyValue);
        break;
    case LT:
        criterion = Restrictions.lt(propertyName, propertyValue);
        break;
    case GE:
        criterion = Restrictions.ge(propertyName, propertyValue);
        break;
    case GT:
        criterion = Restrictions.gt(propertyName, propertyValue);
        break;
    case NE:
        criterion = Restrictions.ne(propertyName, propertyValue);
    }
    return criterion;
}
项目:sjk    文件:AppDaoImpl.java   
private Criteria searchByFilter(Short catalog, Integer subCatalog, String keywords, Integer id) {
    Criteria cri = getSession().createCriteria(App.class);

    if (catalog != null) {
        cri.add(Restrictions.eq("catalog", catalog));
    }
    if (subCatalog != null) {
        cri.add(Restrictions.eq("subCatalog", subCatalog));
    }
    if (id != null && id > 0) {
        cri.add(Restrictions.eq("id", id));
    }
    if (keywords != null && !keywords.isEmpty()) {
        cri.add(Restrictions.like("name", keywords, MatchMode.START));
    }
    return cri;
}
项目:sjk    文件:AppDaoImpl.java   
@Override
public List<Rollinfo> searchForRolling(Short catalog, Integer subCatalog, int page, int rows, String keywords,
        String sort, String order) {
    Criteria cri = getSession().createCriteria(Rollinfo.class);
    Criteria appCriteria = cri.createCriteria("app", JoinType.LEFT_OUTER_JOIN);
    if (catalog != null) {
        appCriteria.add(Restrictions.eq("catalog", catalog));
    }
    if (subCatalog != null) {
        appCriteria.add(Restrictions.eq("subCatalog", subCatalog));
    }

    if (keywords != null && !keywords.isEmpty()) {
        appCriteria.add(Restrictions.like("name", keywords, MatchMode.START));
    }

    if (sort != null && !sort.isEmpty()) {
        HibernateHelper.addOrder(appCriteria, sort, order);
    }
    cri.setMaxResults(rows);
    cri.setFirstResult(HibernateHelper.firstResult(page, rows));
    List<Rollinfo> list = HibernateHelper.list(cri);
    return list;
}
项目:sjk    文件:AppDaoImpl.java   
@Override
public long countForSearchingRolling(Short catalog, Integer subCatalog, String keywords) {
    Criteria cri = getSession().createCriteria(Rollinfo.class);
    Criteria appCriteria = cri.createCriteria("app", JoinType.LEFT_OUTER_JOIN);

    if (catalog != null) {
        appCriteria.add(Restrictions.eq("catalog", catalog));
    }
    if (subCatalog != null) {
        appCriteria.add(Restrictions.eq("subCatalog", subCatalog));
    }

    if (keywords != null && !keywords.isEmpty()) {
        appCriteria.add(Restrictions.like("name", keywords, MatchMode.START));
    }
    cri.setProjection(Projections.rowCount());
    List<Long> list = HibernateHelper.list(cri);
    return list.get(0);
}
项目:sjk    文件:MoMixFeaturedDaoImpl.java   
private Criteria searchByFilter(Short type, Short picType, Boolean hidden, String keywords) {
    Criteria cri = getSession().createCriteria(MoMixFeatured.class);
    if (type != null) {
        cri.add(Restrictions.eq("type", type));
    }
    if (picType != null) {
        cri.add(Restrictions.eq("picType", picType));
    }
    if (hidden != null) {
        cri.add(Restrictions.eq("hidden", hidden));
    }
    if (StringUtils.isNotBlank(keywords)) {
        cri.add(Restrictions.like("name", keywords, MatchMode.ANYWHERE));
    }
    return cri;
}
项目:sjk    文件:AppAndTagDaoImpl.java   
private Criteria searchByFilter(Integer tagId, Integer catalog, Short tagType, String keywords) {
    Criteria cri = getSession().createCriteria(ViewTagApps.class);
    if (tagType != null) {
        cri.add(Restrictions.eq("tagType", tagType));
    }
    if (tagId != null && tagId > 0) {
        cri.add(Restrictions.eq("tagId", tagId));
    }
    if (catalog != null && catalog > 0) {
        cri.add(Restrictions.eq("catalog", catalog));
    }
    if (keywords != null && !keywords.isEmpty()) {
        cri.add(Restrictions.or(Restrictions.like("appName", keywords, MatchMode.ANYWHERE),
                Restrictions.like("marketName", keywords, MatchMode.ANYWHERE),
                Restrictions.like("tagName", keywords, MatchMode.ANYWHERE)));
    }
    return cri;
}
项目:sjk    文件:MarketAppDaoImpl.java   
private Criteria searchByFilter(EnumMarket enumMarket, Short catalog, Integer subCatalog, String keywords,
        Integer id, Date startDate, Date endDate) {
    Criteria cri = getSession().createCriteria(MarketApp.class);
    if (enumMarket != null) {
        cri.add(Restrictions.eq("marketName", enumMarket.getName()));
    }
    if (catalog != null) {
        cri.add(Restrictions.eq("catalog", catalog));
    }
    if (subCatalog != null) {
        cri.add(Restrictions.eq("subCatalog", subCatalog));
    }
    if (id != null && id > 0) {
        cri.add(Restrictions.eq("id", id));
    }
    if (startDate != null && endDate != null) {
        cri.add(Restrictions.between("lastUpdateTime", startDate, endDate));
    }
    if (keywords != null && !keywords.isEmpty()) {
        cri.add(Restrictions.like("name", keywords, MatchMode.ANYWHERE));
    }
    return cri;
}
项目:sjk    文件:MoFeaturedDaoImpl.java   
private Criteria searchByFilter(Short type, Boolean hidden, Boolean deleted, String keywords) {
    Criteria cri = getSession().createCriteria(MoFeatured.class);
    if (type != null) {
        cri.add(Restrictions.eq("type", type));
    }
    if (hidden != null) {
        cri.add(Restrictions.eq("hidden", hidden));
    }
    if (deleted != null) {
        cri.add(Restrictions.eq("deleted", deleted));
    }
    if (StringUtils.isNotBlank(keywords)) {
        cri.add(Restrictions.like("name", keywords, MatchMode.ANYWHERE));
    }
    return cri;
}
项目:sjk    文件:MoAppAndTagDaoImpl.java   
private Criteria searchByFilter(Integer tagId, Integer catalog, Short tagType, String keywords) {
    Criteria cri = getSession().createCriteria(MoViewTagApps.class);
    if (tagType != null) {
        cri.add(Restrictions.eq("tagType", tagType));
    }
    if (tagId != null && tagId > 0) {
        cri.add(Restrictions.eq("tagId", tagId));
    }
    if (catalog != null && catalog > 0) {
        cri.add(Restrictions.eq("catalog", catalog));
    }
    if (keywords != null && !keywords.isEmpty()) {
        cri.add(Restrictions.or(Restrictions.like("appName", keywords, MatchMode.ANYWHERE),
                Restrictions.like("marketName", keywords, MatchMode.ANYWHERE),
                Restrictions.like("tagName", keywords, MatchMode.ANYWHERE)));
    }
    return cri;
}
项目:sjk    文件:TopAppDaoImpl.java   
@Override
public List<TopApp> findTopAppList(String keywords, Integer id, int page, int rows) {
    Criteria cri = getSession().createCriteria(TopApp.class);
    if (id != null && id > 0) {
        cri.add(Restrictions.eq("id", id));
    }
    if (keywords != null && !keywords.isEmpty()) {
        cri.add(Restrictions.like("name", keywords, MatchMode.ANYWHERE));
    }
    cri.add(Restrictions.and(Restrictions.ne("name",""), Restrictions.isNotNull("name")));

    cri.addOrder(Order.desc("state"));
    cri.setMaxResults(rows);
    cri.setFirstResult(HibernateHelper.firstResult(page, rows));
    List<TopApp> list = HibernateHelper.list(cri);
    return list;
}
项目:sjk    文件:AppDaoImpl.java   
@Override
public List<Rollinfo> searchForRolling(Short catalog, Integer subCatalog, int page, int rows, String keywords,
        String sort, String order) {
    Criteria cri = getSession().createCriteria(Rollinfo.class);
    Criteria appCriteria = cri.createCriteria("app", JoinType.LEFT_OUTER_JOIN);
    if (catalog != null) {
        appCriteria.add(Restrictions.eq("catalog", catalog));
    }
    if (subCatalog != null) {
        appCriteria.add(Restrictions.eq("subCatalog", subCatalog));
    }

    if (keywords != null && !keywords.isEmpty()) {
        appCriteria.add(Restrictions.like("name", keywords, MatchMode.ANYWHERE));
    }

    if (sort != null && !sort.isEmpty()) {
        HibernateHelper.addOrder(appCriteria, sort, order);
    }
    cri.setMaxResults(rows);
    cri.setFirstResult(HibernateHelper.firstResult(page, rows));
    List<Rollinfo> list = HibernateHelper.list(cri);
    return list;
}
项目:sjk    文件:AppDaoImpl.java   
@Override
public long countForSearchingRolling(Short catalog, Integer subCatalog, String keywords) {
    Criteria cri = getSession().createCriteria(Rollinfo.class);
    Criteria appCriteria = cri.createCriteria("app", JoinType.LEFT_OUTER_JOIN);

    if (catalog != null) {
        appCriteria.add(Restrictions.eq("catalog", catalog));
    }
    if (subCatalog != null) {
        appCriteria.add(Restrictions.eq("subCatalog", subCatalog));
    }

    if (keywords != null && !keywords.isEmpty()) {
        appCriteria.add(Restrictions.like("name", keywords, MatchMode.ANYWHERE));
    }
    cri.setProjection(Projections.rowCount());
    List<Long> list = HibernateHelper.list(cri);
    return list.get(0);
}
项目:sjk    文件:MarketAppDaoImpl.java   
private Criteria searchByFilter(EnumMarket enumMarket, Short catalog, Integer subCatalog, String keywords) {
    Criteria cri = getSession().createCriteria(MarketApp.class);
    if (enumMarket != null) {
        cri.add(Restrictions.eq("marketName", enumMarket.getName()));
    }
    if (catalog != null) {
        cri.add(Restrictions.eq("catalog", catalog));
    }
    if (subCatalog != null) {
        cri.add(Restrictions.eq("subCatalog", subCatalog));
    }
    if (keywords != null && !keywords.isEmpty()) {
        cri.add(Restrictions.like("name", keywords, MatchMode.ANYWHERE));
    }
    return cri;
}
项目:ctsms    文件:ECRFFieldDaoImpl.java   
@Override
protected Collection<ECRFField> handleFindAllSorted(String nameInfix, Integer limit) throws Exception {
    org.hibernate.Criteria ecrfFieldCriteria = createEcrfFieldCriteria();
    if (!CommonUtil.isEmptyString(nameInfix)) {
        org.hibernate.Criteria trialCriteria = ecrfFieldCriteria.createCriteria("trial", "trial0", CriteriaSpecification.INNER_JOIN);
        org.hibernate.Criteria ecrfCriteria = ecrfFieldCriteria.createCriteria("ecrf", "ecrf0", CriteriaSpecification.INNER_JOIN);
        org.hibernate.Criteria fieldCriteria = ecrfFieldCriteria.createCriteria("field", "inputField", CriteriaSpecification.INNER_JOIN);
        //fieldCriteria.add(Restrictions.eq("localized", false));
        ecrfFieldCriteria.add(Restrictions.or(
                (new CategoryCriterion(nameInfix, "section", MatchMode.ANYWHERE)).getRestriction(),
                Restrictions.or(
                        (new CategoryCriterion(nameInfix, "inputField.nameL10nKey", MatchMode.ANYWHERE)).getRestriction(),
                        Restrictions.or(
                                (new CategoryCriterion(nameInfix, "ecrf0.name", MatchMode.ANYWHERE)).getRestriction(),
                                (new CategoryCriterion(nameInfix, "trial0.name", MatchMode.ANYWHERE)).getRestriction()
                                ))));
    }
    applySortOrders(ecrfFieldCriteria);
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.ECRF_FIELD_FIELD_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS,
            DefaultSettings.ECRF_FIELD_FIELD_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), ecrfFieldCriteria);
    return ecrfFieldCriteria.list();
}
项目:ctsms    文件:ECRFFieldDaoImpl.java   
@Override
protected Collection<String> handleFindSections(Long trialId, Long ecrfId, String sectionPrefix, Integer limit) throws Exception {
    org.hibernate.Criteria ecrfFieldCriteria = createEcrfFieldCriteria();
    if (trialId != null) {
        ecrfFieldCriteria.add(Restrictions.eq("trial.id", trialId.longValue()));
    }
    if (ecrfId != null) {
        ecrfFieldCriteria.add(Restrictions.eq("ecrf.id", ecrfId.longValue()));
    }
    // if (active != null) {
    // ecrfFieldCriteria.add(Restrictions.eq("active", active.booleanValue()));
    // }
    CategoryCriterion.apply(ecrfFieldCriteria, new CategoryCriterion(sectionPrefix, "section", MatchMode.START));
    ecrfFieldCriteria.addOrder(Order.asc("section"));
    ecrfFieldCriteria.setProjection(Projections.distinct(Projections.property("section")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.ECRF_FIELD_SECTION_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS,
            DefaultSettings.ECRF_FIELD_SECTION_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), ecrfFieldCriteria);
    return ecrfFieldCriteria.list();
}
项目:ctsms    文件:InputFieldSelectionSetValueDaoImpl.java   
private  static void applyUsedByCriterions(org.hibernate.Criteria selectionSetValueCriteria, String nameInfix, String inputFieldProperty) {
    if (selectionSetValueCriteria != null) {
        org.hibernate.Criteria fieldCriteria = selectionSetValueCriteria.createCriteria("field","inputField", CriteriaSpecification.INNER_JOIN);
        if (!CommonUtil.isEmptyString(inputFieldProperty)) {
            fieldCriteria.add(Restrictions.not(Restrictions.isEmpty(inputFieldProperty)));
        }
        //fieldCriteria.add(Restrictions.eq("localized", false));
        if (!CommonUtil.isEmptyString(nameInfix)) {
            selectionSetValueCriteria.add(Restrictions.or(
                    (new CategoryCriterion(nameInfix, "inputField.nameL10nKey", MatchMode.ANYWHERE)).getRestriction(),
                    (new CategoryCriterion(nameInfix, "nameL10nKey", MatchMode.ANYWHERE)).getRestriction()
                    ));
        }

    }
}
项目:ctsms    文件:InquiryDaoImpl.java   
@Override
protected Collection<Inquiry> handleFindAllSorted(String nameInfix, Integer limit) throws Exception {
    org.hibernate.Criteria inquiryCriteria = createInquiryCriteria();
    if (!CommonUtil.isEmptyString(nameInfix)) {
        org.hibernate.Criteria trialCriteria = inquiryCriteria.createCriteria("trial", "trial0", CriteriaSpecification.INNER_JOIN);
        org.hibernate.Criteria fieldCriteria = inquiryCriteria.createCriteria("field", "inputField", CriteriaSpecification.INNER_JOIN);
        //fieldCriteria.add(Restrictions.eq("localized", false));
        inquiryCriteria.add(Restrictions.or(
                (new CategoryCriterion(nameInfix, "category", MatchMode.ANYWHERE)).getRestriction(),
                Restrictions.or(
                        (new CategoryCriterion(nameInfix, "inputField.nameL10nKey", MatchMode.ANYWHERE)).getRestriction(),
                        (new CategoryCriterion(nameInfix, "trial0.name", MatchMode.ANYWHERE)).getRestriction()
                        )));
    }
    applySortOrders(inquiryCriteria);
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.INQUIRY_FIELD_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS,
            DefaultSettings.INQUIRY_FIELD_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), inquiryCriteria);
    return inquiryCriteria.list();
}
项目:ctsms    文件:InquiryDaoImpl.java   
@Override
protected Collection<String> handleFindCategories(Long trialId,
        String categoryPrefix, Boolean active, Boolean activeSignup, Integer limit) throws Exception {
    org.hibernate.Criteria inquiryCriteria = createInquiryCriteria();
    if (trialId != null) {
        inquiryCriteria.add(Restrictions.eq("trial.id", trialId.longValue()));
    }
    if (active != null) {
        inquiryCriteria.add(Restrictions.eq("active", active.booleanValue()));
    }
    if (activeSignup != null) {
        inquiryCriteria.add(Restrictions.eq("activeSignup", activeSignup.booleanValue()));
    }
    CategoryCriterion.apply(inquiryCriteria, new CategoryCriterion(categoryPrefix, "category", MatchMode.START));
    inquiryCriteria.addOrder(Order.asc("category"));
    inquiryCriteria.setProjection(Projections.distinct(Projections.property("category")));
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.INQUIRY_CATEGORY_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS,
            DefaultSettings.INQUIRY_CATEGORY_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), inquiryCriteria);
    return inquiryCriteria.list();
}
项目:ctsms    文件:AspSubstanceDaoImpl.java   
private static void applyAspSubstanceNameCriterions(org.hibernate.Criteria aspSubstanceCriteria, String nameInfix) {
    String revision =  Settings.getString(SettingCodes.ASP_REVISION, Bundle.SETTINGS, DefaultSettings.ASP_REVISION);
    ArrayList<CategoryCriterion> criterions = new ArrayList<CategoryCriterion>();
    criterions.add(new CategoryCriterion(nameInfix, "name", MatchMode.ANYWHERE));
    if (MATCH_ASP_NAME || MATCH_ASP_REGISTRATION_NUMBER || MATCH_ATC_CODE_CODE) {
        org.hibernate.Criteria aspsCriteria = aspSubstanceCriteria.createCriteria("asps", "asps0", CriteriaSpecification.LEFT_JOIN);
        if (MATCH_ASP_NAME) {
            criterions.add(new CategoryCriterion(nameInfix, "asps0.name", MatchMode.ANYWHERE));
        }
        if (MATCH_ASP_REGISTRATION_NUMBER) {
            criterions.add(new CategoryCriterion(nameInfix, "asps0.registrationNumber", MatchMode.EXACT));
        }
        aspsCriteria.add(Restrictions.eq("revision", revision));
        if (MATCH_ATC_CODE_CODE) {
            org.hibernate.Criteria atcCodesCriteria = aspsCriteria.createCriteria("atcCodes", "atcCodes0", CriteriaSpecification.LEFT_JOIN);
            atcCodesCriteria.add(Restrictions.eq("revision", revision));
            criterions.add(new CategoryCriterion(nameInfix, "atcCodes0.code", MatchMode.EXACT));
        }
    }

    CategoryCriterion.applyOr(aspSubstanceCriteria, criterions);
    aspSubstanceCriteria.add(Restrictions.eq("revision", revision));

}
项目:ctsms    文件:AspDaoImpl.java   
private static void applyAspNameCriterions(org.hibernate.Criteria aspCriteria, String nameInfix) {
    String revision =  Settings.getString(SettingCodes.ASP_REVISION, Bundle.SETTINGS, DefaultSettings.ASP_REVISION);
    ArrayList<CategoryCriterion> criterions = new ArrayList<CategoryCriterion>();
    criterions.add(new CategoryCriterion(nameInfix, "name", MatchMode.ANYWHERE));
    if (MATCH_REGISTRATION_NUMBER) {
        criterions.add(new CategoryCriterion(nameInfix, "registrationNumber", MatchMode.EXACT));
    }
    if (MATCH_SUBSTANCE_NAME) {
        org.hibernate.Criteria substancesCriteria = aspCriteria.createCriteria("substances", "substances0", CriteriaSpecification.LEFT_JOIN);
        substancesCriteria.add(Restrictions.eq("revision", revision));
        criterions.add(new CategoryCriterion(nameInfix, "substances0.name", MatchMode.ANYWHERE));
    }
    if (MATCH_ATC_CODE_CODE) {
        org.hibernate.Criteria atcCodesCriteria = aspCriteria.createCriteria("atcCodes", "atcCodes0", CriteriaSpecification.LEFT_JOIN);
        atcCodesCriteria.add(Restrictions.eq("revision", revision));
        criterions.add(new CategoryCriterion(nameInfix, "atcCodes0.code", MatchMode.EXACT));
    }
    CategoryCriterion.applyOr(aspCriteria, criterions);
    aspCriteria.add(Restrictions.eq("revision", revision));
}
项目:ctsms    文件:ProbandListEntryTagDaoImpl.java   
@Override
protected Collection<ProbandListEntryTag> handleFindAllSorted(String nameInfix, Integer limit) throws Exception {
    org.hibernate.Criteria listEntryTagCriteria = createListEntryTagCriteria();
    if (!CommonUtil.isEmptyString(nameInfix)) {
        org.hibernate.Criteria trialCriteria = listEntryTagCriteria.createCriteria("trial", "trial0", CriteriaSpecification.INNER_JOIN);
        org.hibernate.Criteria fieldCriteria = listEntryTagCriteria.createCriteria("field", "inputField", CriteriaSpecification.INNER_JOIN);
        //fieldCriteria.add(Restrictions.eq("localized", false));
        listEntryTagCriteria.add(Restrictions.or(
                (new CategoryCriterion(nameInfix, "inputField.nameL10nKey", MatchMode.ANYWHERE)).getRestriction(),
                (new CategoryCriterion(nameInfix, "trial0.name", MatchMode.ANYWHERE)).getRestriction()
                ));
    }
    applySortOrders(listEntryTagCriteria);
    CriteriaUtil.applyLimit(limit, Settings.getIntNullable(SettingCodes.PROBAND_LIST_ENTRY_TAG_FIELD_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS,
            DefaultSettings.PROBAND_LIST_ENTRY_TAG_FIELD_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT), listEntryTagCriteria);
    return listEntryTagCriteria.list();
}
项目:ctsms    文件:MoneyTransferDaoImpl.java   
@Override
protected long handleGetCount(Long trialId, Long probandId, Long bankAccountId, PaymentMethod method, String costType, Boolean paid) throws Exception
{
    org.hibernate.Criteria moneyTransferCriteria = createMoneyTransferCriteria("moneyTransfer");
    //moneyTransferCriteria.add(Restrictions.isNull("trial.id"));
    if (trialId != null) {
        moneyTransferCriteria.add(Restrictions.eq("trial.id", trialId.longValue()));
    }
    if (probandId != null) {
        moneyTransferCriteria.add(Restrictions.eq("proband.id", probandId.longValue()));
    }
    if (bankAccountId != null) {
        moneyTransferCriteria.add(Restrictions.eq("bankAccount.id", bankAccountId.longValue()));
    }
    if (method != null) {
        moneyTransferCriteria.add(Restrictions.eq("method", method));
    }
    if (paid != null) {
        moneyTransferCriteria.add(Restrictions.eq("paid", paid.booleanValue()));
    }
    CategoryCriterion.apply(moneyTransferCriteria, new CategoryCriterion(costType, "costType", MatchMode.EXACT, EmptyPrefixModes.ALL_ROWS));
    return (Long) moneyTransferCriteria.setProjection(Projections.rowCount()).uniqueResult();
}
项目:ctsms    文件:InventoryBookingDaoImpl.java   
/**
 * @inheritDoc
 */
@Override
protected Collection<InventoryBooking> handleFindByProbandCalendarInterval(Long probandId, String calendar, Timestamp from, Timestamp to,
        Boolean isRelevantForProbandAppointments) throws Exception
        {
    Criteria bookingCriteria = createBookingCriteria();
    CriteriaUtil.applyClosedIntervalCriterion(bookingCriteria, from, to, null);
    if (probandId != null) {
        bookingCriteria.add(Restrictions.eq("proband.id", probandId.longValue()));
    }
    if (isRelevantForProbandAppointments != null) {
        bookingCriteria.createCriteria("inventory", CriteriaSpecification.INNER_JOIN).createCriteria("category", CriteriaSpecification.INNER_JOIN)
        .add(Restrictions.eq("relevantForProbandAppointments", isRelevantForProbandAppointments.booleanValue()));
    }
    CategoryCriterion.apply(bookingCriteria, new CategoryCriterion(calendar, "calendar", MatchMode.EXACT, EmptyPrefixModes.ALL_ROWS));
    return bookingCriteria.list();
        }
项目:ctsms    文件:InventoryBookingDaoImpl.java   
@Override
protected Collection<InventoryBooking> handleFindByTrialCalendarInterval(
        Long trialId, String calendar, Timestamp from, Timestamp to,
        Boolean isRelevantForTrialAppointments) throws Exception {
    Criteria bookingCriteria = createBookingCriteria();
    CriteriaUtil.applyClosedIntervalCriterion(bookingCriteria, from, to, null);
    if (trialId != null) {
        bookingCriteria.add(Restrictions.eq("trial.id", trialId.longValue()));
    }
    if (isRelevantForTrialAppointments != null) {
        bookingCriteria.createCriteria("inventory", CriteriaSpecification.INNER_JOIN).createCriteria("category", CriteriaSpecification.INNER_JOIN)
        .add(Restrictions.eq("relevantForTrialAppointments", isRelevantForTrialAppointments.booleanValue()));
    }
    CategoryCriterion.apply(bookingCriteria, new CategoryCriterion(calendar, "calendar", MatchMode.EXACT, EmptyPrefixModes.ALL_ROWS));
    return bookingCriteria.list();
}
项目:ctsms    文件:StreetDaoImpl.java   
/**
 * @inheritDoc
 */
@Override
protected Collection<String> handleFindZipCodes(String countryName, String zipCodePrefix, String cityName, String streetName, Integer limit)
{
    org.hibernate.Criteria streetCriteria = createStreetCriteria();
    if (!CommonUtil.isEmptyString(countryName)) {
        streetCriteria.add(Restrictions.eq("countryName", countryName));
    }
    CategoryCriterion.apply(streetCriteria, new CategoryCriterion(zipCodePrefix, "zipCode", MatchMode.START));
    if (!CommonUtil.isEmptyString(cityName)) {
        streetCriteria.add(Restrictions.eq("cityName", cityName));
    }
    if (!CommonUtil.isEmptyString(streetName)) {
        streetCriteria.add(Restrictions.eq("streetName", streetName));
    }
    streetCriteria.add(Restrictions.not(Restrictions.or(Restrictions.eq("zipCode", ""), Restrictions.isNull("zipCode"))));
    streetCriteria.addOrder(Order.asc("zipCode"));
    streetCriteria.setProjection(Projections.distinct(Projections.property("zipCode")));
    CriteriaUtil.applyLimit(limit,
            Settings.getIntNullable(SettingCodes.ZIP_CODE_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT, Bundle.SETTINGS, DefaultSettings.ZIP_CODE_AUTOCOMPLETE_DEFAULT_RESULT_LIMIT),
            streetCriteria);
    return streetCriteria.list();
}
项目:ctsms    文件:TrialDaoImpl.java   
@Override
protected Collection<Trial> handleFindByReimbursementProbandSorted(
        Long probandId, PaymentMethod method, String costType, Boolean paid) throws Exception {
    org.hibernate.Criteria trialCriteria = createTrialCriteria(null);
    Criteria payoffCriteria = trialCriteria.createCriteria("payoffs", CriteriaSpecification.INNER_JOIN);
    payoffCriteria.add(Restrictions.eq("proband.id", probandId.longValue()));
    if (method != null) {
        payoffCriteria.add(Restrictions.eq("method", method));
    }
    if (paid != null) {
        payoffCriteria.add(Restrictions.eq("paid", paid.booleanValue()));
    }
    CategoryCriterion.apply(payoffCriteria, new CategoryCriterion(costType, "costType", MatchMode.EXACT, EmptyPrefixModes.ALL_ROWS));
    trialCriteria.addOrder(Order.asc("name"));
    // trialCriteria.setResultTransformer(org.hibernate.Criteria.DISTINCT_ROOT_ENTITY);
    // return trialCriteria.list();
    return CriteriaUtil.listDistinctRoot(trialCriteria, this, "name");
}
项目:dswork    文件:HbmDemoDao.java   
@Override
protected void queryParam(Map map, Criteria criteria)
{
    Object tmp;
    tmp = map.get("title");
    if(tmp != null)
    {
        criteria.add(Restrictions.like("title", String.valueOf(tmp).trim(), MatchMode.ANYWHERE));
    }
    tmp = map.get("content");
    if(tmp != null)
    {
        criteria.add(Restrictions.like("content", String.valueOf(tmp).trim(), MatchMode.ANYWHERE));
    }
    tmp = map.get("foundtime");
    if(tmp != null)
    {
        criteria.add(Restrictions.like("foundtime", String.valueOf(tmp).trim(), MatchMode.ANYWHERE));
    }
    criteria.addOrder(Order.desc("foundtime"));
    criteria.addOrder(Order.asc("id"));
}
项目:dswork    文件:HbmDemoDao.java   
@Override
protected void queryParam(Map map, Criteria criteria)
{
    Object tmp;
        tmp = map.get("id");
    if(tmp != null)
    {
        criteria.add(Restrictions.eq("id", String.valueOf(tmp).trim()));
    }
    tmp = map.get("title");
    if(tmp != null)
    {
        criteria.add(Restrictions.like("title", String.valueOf(tmp).trim(), MatchMode.ANYWHERE));
    }
    tmp = map.get("content");
    if(tmp != null)
    {
        criteria.add(Restrictions.like("content", String.valueOf(tmp).trim(), MatchMode.ANYWHERE));
    }
    tmp = map.get("foundtime");
    if(tmp != null)
    {
        criteria.add(Restrictions.like("foundtime", String.valueOf(tmp).trim(), MatchMode.ANYWHERE));
    }
}
项目:Spring_1    文件:LearnHubDaoImpl.java   
@SuppressWarnings("unchecked")
//@Cacheable(value = { "course" },key="#title")
public List<Course> findCourseByTitle(String title, int page, String sortColmName, String sortby) {
    Criteria crt = getSession().createCriteria(Course.class);
    crt.add(Restrictions.like("title",  title, MatchMode.ANYWHERE));
    if(page > 0){
        crt.setMaxResults(5);
        crt.setFirstResult(5* (page-1));
    }
    if(! StringUtils.isEmpty(sortColmName) &&  ! StringUtils.isEmpty(sortby)){
        if("desc".equalsIgnoreCase(sortby)){
            crt.addOrder(Order.desc(sortColmName));
        }else{
            crt.addOrder(Order.asc(sortColmName));
        }
    }

    List<Course> courses = crt.list();
    return courses;
}
项目:mblog    文件:PostDaoImpl.java   
@Override
public List<PostPO> paging4Admin(Paging paging, long id, String title, int group) {
    PagingQuery<PostPO> q = pagingQuery(paging);

    if (group > Const.ZERO) {
        q.add(Restrictions.eq("group", group));
    }

    if (StringUtils.isNotBlank(title)) {
        q.add(Restrictions.like("title", title, MatchMode.ANYWHERE));
    }

    if (id > Const.ZERO) {
        q.add(Restrictions.eq("id", id));
    }
    q.desc("featured");
    q.desc("created");
    return q.list();
}
项目:java-project    文件:ArticleDaoImpl.java   
/**
 * 根据输入内容搜素符合条件的文章
 */
@SuppressWarnings("unchecked")
public List<Article> doSearch(String type, String str, String firstResult,
        String maxResults) {
    int first = new Integer(firstResult).intValue();
    int max = new Integer(maxResults).intValue();
    Criteria criteria = this.getCriteria(Article.class);
    if (type != null && !type.equals("")) {
        criteria.add(Restrictions.eq("articleTypeName", type));
    }
    criteria.add(
            Restrictions.or(Restrictions.like("title", str,
                    MatchMode.ANYWHERE), Restrictions.like("content", str,
                    MatchMode.ANYWHERE))).addOrder(
            Order.desc("lastUpdateTime")).setFirstResult(first)
            .setMaxResults(max);
    List<Article> list = criteria.list();
    return list;
}
项目:SalesStore    文件:AchatDaoImpl.java   
public int findAllCount(Achat achat) {
    Criteria criteria=getCurrentSession().createCriteria(Achat.class);
    String title =achat.getTitle() ;
    String content = achat.getContent() ;
    String support_id = achat.getSupport_id() ;
    String state = achat.getState() ;
    String create_user = achat.getCreate_user() ;
    if(!StringUtil.isNullOrEmpty(title)){
        criteria.add(Restrictions.like("title", title, MatchMode.ANYWHERE).ignoreCase());
    }
    if(!StringUtil.isNullOrEmpty(content)){
        criteria.add(Restrictions.like("content", content, MatchMode.ANYWHERE).ignoreCase());
    }
    if(!StringUtil.isNullOrEmpty(support_id)){
        criteria.add(Restrictions.eq("support_id", support_id));
    }
    if(!StringUtil.isNullOrEmpty(state)){
        criteria.add(Restrictions.eq("state", state));
    }
    if(!StringUtil.isNullOrEmpty(create_user)){
        criteria.add(Restrictions.eq("create_user", create_user));
    }
    List<Achat> list = criteria.list() ;
    return list.size();
}
项目:SalesStore    文件:UserDaoImpl.java   
public int findAllCountLike(User user) {
    Criteria criteria=getCurrentSession().createCriteria(User.class);
    String username =user.getUsername() ;
    String realname = user.getRealname() ;
    String role_id = user.getRole_id() ;
    if(!StringUtil.isNullOrEmpty(username)){
        criteria.add(Restrictions.like("username", username, MatchMode.ANYWHERE).ignoreCase());
    }
    if(!StringUtil.isNullOrEmpty(realname)){
        criteria.add(Restrictions.like("realname", realname, MatchMode.ANYWHERE).ignoreCase());
    }
    if(!StringUtil.isNullOrEmpty(role_id)){
        criteria.add(Restrictions.like("role_id", role_id, MatchMode.ANYWHERE).ignoreCase());
    }
    List<User> list = criteria.list() ;
    return list.size();
}
项目:Cloud-Deployment    文件:LearnHubDaoImpl.java   
@SuppressWarnings("unchecked")
//@Cacheable(value = { "course" },key="#title")
public List<Course> findCourseByTitle(String title, int page, String sortColmName, String sortby) {
    Criteria crt = getSession().createCriteria(Course.class);
    crt.add(Restrictions.like("title",  title, MatchMode.ANYWHERE));
    if(page > 0){
        crt.setMaxResults(5);
        crt.setFirstResult(5* (page-1));
    }
    if(! StringUtils.isEmpty(sortColmName) &&  ! StringUtils.isEmpty(sortby)){
        if("desc".equalsIgnoreCase(sortby)){
            crt.addOrder(Order.desc(sortColmName));
        }else{
            crt.addOrder(Order.asc(sortColmName));
        }
    }

    List<Course> courses = crt.list();
    return courses;
}
项目:hibernate-filter    文件:RestrictionStrategyImpl.java   
protected Criterion restrictionLike(String key, String value) {
    switch (this.reflectionStrategy.returnType(this.table, key)) {
        case "Long": {
            try {
                return Restrictions.sqlRestriction("{" + this.reflectionStrategy.entityName(key) + "}"
                        + "." + this.reflectionStrategy.columnName(this.table, key) + " LIKE '%" + Long.parseLong(value) + "%'");
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }
        }
        case "String": {
            return Restrictions.like(restrictionKeyCrop(key), value, MatchMode.ANYWHERE).ignoreCase();
        }
    }
    return null;
}