~ubuntu-branches/ubuntu/wily/libhibernate3-java/wily-proposed

« back to all changes in this revision

Viewing changes to src/org/hibernate/criterion/RowCountProjection.java

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2007-10-14 14:43:34 UTC
  • Revision ID: james.westby@ubuntu.com-20071014144334-eamc8i0q10gs1aro
Tags: upstream-3.2.5
ImportĀ upstreamĀ versionĀ 3.2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//$Id: RowCountProjection.java 9908 2006-05-08 20:59:20Z max.andersen@jboss.com $
 
2
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
/**
 
10
 * A row count
 
11
 * @author Gavin King
 
12
 */
 
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
}