Java Code Examples for javax.persistence.criteria.CriteriaBuilder.lower()

The following are Jave code examples for showing how to use lower() of the javax.persistence.criteria.CriteriaBuilder class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: OperatieBRP   File: LeveringsautorisatieFilterFactory.java   Source Code and License Vote up 6 votes
@Override
public Predicate toPredicate(final Root<?> leveringsautorisatieRoot, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
    final Root<Dienstbundel> dienstbundelRoot = query.from(Dienstbundel.class);

    // Join dienst op leveringsautorisatie
    final Predicate joinPredicateLeveringsautorisatie = leveringsautorisatieRoot.get(ID).in(dienstbundelRoot.get(LEVERINGSAUTORISATIE).get(ID));

    // Dienstbundel
    final Expression<String> attributeExpression = cb.lower(cb.function(UNACCENT, String.class, dienstbundelRoot.get("naam")));
    final Expression<String> valueExpression =
            cb.lower(
                    cb.function(
                            UNACCENT,
                            String.class,
                            cb.concat(cb.concat(cb.literal(WILDCARD), cb.literal(value.toString())), cb.literal(WILDCARD))));
    final Predicate dienstBundelPredicate = cb.like(attributeExpression, valueExpression);

    return cb.and(joinPredicateLeveringsautorisatie, dienstBundelPredicate);
}
 
Example 2
Project: OperatieBRP   File: PersoonFilterFactory.java   Source Code and License Vote up 6 votes
@Override
public Predicate toPredicate(final Root<?> persoonRoot, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
    final Root<PersoonAdres> persoonAdressenRoot = query.from(PersoonAdres.class);
    final Predicate joinPredicateAdressen = persoonRoot.get(ID).in(persoonAdressenRoot.get(PERSOON).get(ID));
    final Predicate adresPredicate;
    if (likePredicate) {
        final Expression<String> attributeExpression = cb.lower(cb.function(UNACCENT, String.class, persoonAdressenRoot.get(field)));
        final Expression<String> valueExpression =
                cb.lower(
                        cb.function(
                                UNACCENT,
                                String.class,
                                cb.concat(cb.concat(cb.literal(WILDCARD), cb.literal(value.toString())), cb.literal(WILDCARD))));
        adresPredicate = cb.like(attributeExpression, valueExpression);
    } else {
        adresPredicate = cb.equal(persoonAdressenRoot.get(field), value);
    }
    return cb.and(joinPredicateAdressen, adresPredicate);
}
 
Example 3
Project: OperatieBRP   File: LikePredicateBuilder.java   Source Code and License Vote up 5 votes
@Override
public Predicate toPredicate(final Root<?> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
    // Like en case insensitive
    final Path<String> path = PredicateBuilderUtil.<String>getPath(root, naam);
    final Expression<String> attributeExpression = cb.lower(cb.function(UNACCENT, String.class, path));
    final Expression<String> valueExpression =
            cb.lower(cb.function(UNACCENT, String.class, cb.concat(cb.concat(cb.literal(WILDCARD), cb.literal(value.toString())), cb.literal(WILDCARD))));

    return cb.like(attributeExpression, valueExpression);
}
 
Example 4
Project: OperatieBRP   File: PersoonFilterFactory.java   Source Code and License Vote up 5 votes
@Override
public Predicate toPredicate(final Root<?> persoonRoot, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
    final Root<PersoonAdres> persoonAdressenRoot = query.from(PersoonAdres.class);
    final Predicate joinPredicateAdressen = persoonRoot.get(ID).in(persoonAdressenRoot.get(PERSOON).get(ID));

    final Expression<String> attributeExpression1 =
            cb.lower(cb.function(UNACCENT, String.class, persoonAdressenRoot.get("buitenlandsAdresRegel1")));
    final Expression<String> attributeExpression2 =
            cb.lower(cb.function(UNACCENT, String.class, persoonAdressenRoot.get("buitenlandsAdresRegel2")));
    final Expression<String> attributeExpression3 =
            cb.lower(cb.function(UNACCENT, String.class, persoonAdressenRoot.get("buitenlandsAdresRegel3")));
    final Expression<String> attributeExpression4 =
            cb.lower(cb.function(UNACCENT, String.class, persoonAdressenRoot.get("buitenlandsAdresRegel4")));
    final Expression<String> attributeExpression5 =
            cb.lower(cb.function(UNACCENT, String.class, persoonAdressenRoot.get("buitenlandsAdresRegel5")));
    final Expression<String> attributeExpression6 =
            cb.lower(cb.function(UNACCENT, String.class, persoonAdressenRoot.get("buitenlandsAdresRegel6")));
    final Expression<String> valueExpression =
            cb.lower(
                    cb.function(
                            UNACCENT,
                            String.class,
                            cb.concat(cb.concat(cb.literal(WILDCARD), cb.literal(value.toString())), cb.literal(WILDCARD))));
    final Predicate adresPredicate1 = cb.like(attributeExpression1, valueExpression);
    final Predicate adresPredicate2 = cb.like(attributeExpression2, valueExpression);
    final Predicate adresPredicate3 = cb.like(attributeExpression3, valueExpression);
    final Predicate adresPredicate4 = cb.like(attributeExpression4, valueExpression);
    final Predicate adresPredicate5 = cb.like(attributeExpression5, valueExpression);
    final Predicate adresPredicate6 = cb.like(attributeExpression6, valueExpression);

    final Predicate buitenlandsAdres = cb.or(adresPredicate1, adresPredicate2, adresPredicate3, adresPredicate4, adresPredicate5, adresPredicate6);
    return cb.and(joinPredicateAdressen, buitenlandsAdres);
}