Example usage for org.hibernate.criterion ProjectionList toString

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

Introduction

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

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:org.apache.usergrid.apm.service.SessionDBServiceImpl.java

License:Apache License

@SuppressWarnings("unchecked")
@Override/*from  w ww  .ja v  a  2 s.  com*/
public List<CompactSessionMetrics> getCompactSessionMetrics(List<Criterion> criteria,
        ProjectionList projections, List<Order> orders) throws HibernateException {
    log.info("Getting data from compact session metrics table " + criteria.toString());
    List<CompactSessionMetrics> hcsms = null;
    Session session = null;
    Transaction transaction = null;
    try {
        session = ServiceFactory.getAnalyticsHibernateSession();
        transaction = session.beginTransaction();
        Criteria crit = session.createCriteria(CompactSessionMetrics.class);
        if (criteria != null) {
            Iterator<Criterion> it = criteria.iterator();
            while (it.hasNext()) {
                crit.add(it.next());
            }
        }
        if (orders != null) {
            Iterator<Order> it = orders.iterator();
            while (it.hasNext()) {
                crit.addOrder(it.next());
            }
        }

        crit.setProjection(projections);
        log.info("getting session metrics with " + " criteria " + criteria.toString() + " groupby "
                + projections.toString() + " orders " + orders.toString());
        hcsms = crit.list();
        transaction.commit();
    } catch (Exception e) {
        e.printStackTrace();
        transaction.rollback();
        throw new HibernateException("Cannot get network metrics. ", e);
    }

    return null;
}