Example usage for org.springframework.dao.support DataAccessUtils longResult

List of usage examples for org.springframework.dao.support DataAccessUtils longResult

Introduction

In this page you can find the example usage for org.springframework.dao.support DataAccessUtils longResult.

Prototype

public static long longResult(@Nullable Collection<?> results)
        throws IncorrectResultSizeDataAccessException, TypeMismatchDataAccessException 

Source Link

Document

Return a unique long result from the given Collection.

Usage

From source file:de.forsthaus.backend.dao.impl.CustomerDAOImpl.java

@Override
public int getMaxCustomerId() {
    DetachedCriteria criteria = DetachedCriteria.forClass(Customer.class);
    criteria.setProjection(Projections.projectionList().add(Projections.max("id")));

    long max = DataAccessUtils.longResult(getHibernateTemplate().findByCriteria(criteria));
    return (int) max;
}

From source file:org.pssframework.dao.BaseHibernateDao.java

public long queryForLong(final String queryString, Object[] values) {
    return DataAccessUtils.longResult(getHibernateTemplate().find(queryString, values));
}