java.lang.Object
com.atlassian.bamboo.hibernate.callbacks.RowCount
All Implemented Interfaces:
org.springframework.orm.hibernate5.HibernateCallback<Long>

public class RowCount extends Object implements org.springframework.orm.hibernate5.HibernateCallback<Long>
Callback to be used when there's a need to count records in the table. Due to limitations of HibernateTemplate wrt to DetachedCriteria this callback should only be executed with native session.
  • Method Summary

    Modifier and Type
    Method
    Description
    doInHibernate(org.hibernate.Session session)
     
    static long
    execute(org.springframework.orm.hibernate5.HibernateTemplate hibernateTemplate, Class<?> persistentClass)
    Count all entities for a given class
    static long
    execute(org.springframework.orm.hibernate5.HibernateTemplate hibernateTemplate, org.hibernate.criterion.DetachedCriteria criteria)
    Count all entities for a given criteria

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • doInHibernate

      public Long doInHibernate(org.hibernate.Session session) throws org.hibernate.HibernateException
      Specified by:
      doInHibernate in interface org.springframework.orm.hibernate5.HibernateCallback<Long>
      Throws:
      org.hibernate.HibernateException
    • execute

      public static long execute(org.springframework.orm.hibernate5.HibernateTemplate hibernateTemplate, Class<?> persistentClass)
      Count all entities for a given class
      Parameters:
      hibernateTemplate - Hibernate template
      persistentClass - class for which count query will be run
      Returns:
      number of entries of a given class in database (result of SELECT COUNT(*) query)
    • execute

      public static long execute(org.springframework.orm.hibernate5.HibernateTemplate hibernateTemplate, org.hibernate.criterion.DetachedCriteria criteria)
      Count all entities for a given criteria
      Parameters:
      hibernateTemplate - Hibernate template
      criteria - critiera for which count query will be run
      Returns:
      number of entries in database that match given criteria (result of SELECT COUNT(*) query)