Example usage for org.hibernate.criterion Example setEscapeCharacter

List of usage examples for org.hibernate.criterion Example setEscapeCharacter

Introduction

In this page you can find the example usage for org.hibernate.criterion Example setEscapeCharacter.

Prototype

public Example setEscapeCharacter(Character escapeCharacter) 

Source Link

Document

Set escape character for "like" clause if like matching was enabled

Usage

From source file:py.una.pol.karaku.dao.impl.BaseDAOImpl.java

License:Open Source License

protected Criteria generateWhere(final Where<T> where, @Nonnull final Map<String, String> alias,
        Criteria criteria) {/*from   www.  j  a  va2  s. c  o  m*/

    if (where != null) {
        EntityExample<T> example = where.getExample();
        if (example != null && example.getEntity() != null) {
            Example ejemplo = Example.create(example.getEntity());
            ejemplo.enableLike(example.getMatchMode().getMatchMode());
            ejemplo.setEscapeCharacter('\\');
            if (example.isIgnoreCase()) {
                ejemplo.ignoreCase();
            }
            if (example.isExcludeZeroes()) {
                ejemplo.excludeZeroes();
            }
            criteria.add(ejemplo);
            if (example.getExcluded() != null) {
                for (String excluded : example.getExcluded()) {
                    ejemplo.excludeProperty(excluded);
                }
            }
            this.configureExample(criteria, example.getEntity());
        }
        for (String s : where.getFetchs()) {
            criteria.setFetchMode(s, FetchMode.JOIN);
        }
        helper.applyClauses(criteria, where, alias);
    }

    return criteria;
}