1 package org.hibernate.criterion; 3 4 import org.hibernate.Criteria; 5 import org.hibernate.Hibernate; 6 import org.hibernate.HibernateException; 7 import org.hibernate.type.Type; 8 9 13 public class RowCountProjection extends SimpleProjection { 14 15 protected RowCountProjection() {} 16 17 public String toString() { 18 return "count(*)"; 19 } 20 21 public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery) 22 throws HibernateException { 23 return new Type[] { Hibernate.INTEGER }; 24 } 25 26 public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery) 27 throws HibernateException { 28 return new StringBuffer () 29 .append("count(*) as y") 30 .append(position) 31 .append('_') 32 .toString(); 33 } 34 35 } 36 | Popular Tags |