Class RowCount
- 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 ofHibernateTemplate
wrt toDetachedCriteria
this callback should only be executed with native session.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Long
doInHibernate(org.hibernate.Session session)
static long
execute(org.springframework.orm.hibernate5.HibernateTemplate hibernateTemplate, Class<?> persistentClass)
Count all entities for a given classstatic long
execute(org.springframework.orm.hibernate5.HibernateTemplate hibernateTemplate, org.hibernate.criterion.DetachedCriteria criteria)
Count all entities for a given criteria
-
-
-
Method Detail
-
doInHibernate
public Long doInHibernate(org.hibernate.Session session) throws org.hibernate.HibernateException
- Specified by:
doInHibernate
in interfaceorg.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 templatepersistentClass
- 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 templatecriteria
- critiera for which count query will be run- Returns:
- number of entries in database that match given criteria (result of SELECT COUNT(*) query)
-
-