Example usage for org.hibernate.criterion Example toString

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

Introduction

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

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:fr.xebia.demo.wicket.blog.service.GenericService.java

License:Apache License

@SuppressWarnings("unchecked")
public List<T> search(final T exampleEntity) throws ServiceException {
    try {//w  w w .  java2  s  . c  om
        Validate.notNull(exampleEntity, "Example entity must not be null");
        logger.debug("Search: " + exampleEntity.toString());
        Session session = ((Session) currentEntityManager().getDelegate());
        Criteria criteria = session.createCriteria(getObjectClass());
        Example example = Example.create(exampleEntity);
        example.setPropertySelector(NOT_NULL_OR_EMPTY);
        example.ignoreCase();
        example.enableLike();
        logger.debug("Search example object: " + example.toString());
        criteria.add(example);
        criteria.setMaxResults(getMaxResults());
        criteria.setCacheable(true);
        return criteria.list();
    } catch (PersistenceException e) {
        logger.error(e.getCause(), e);
        throw new ServiceException("Can't search object list from database", e);
    } finally {
        closeEntityManager();
    }
}