1 package org.hibernate.criterion; 3 4 import org.hibernate.Criteria; 5 import org.hibernate.HibernateException; 6 import org.hibernate.type.Type; 7 8 11 public class AliasedProjection implements Projection { 12 13 private final Projection projection; 14 private final String alias; 15 16 public String toString() { 17 return projection.toString() + " as " + alias; 18 } 19 20 protected AliasedProjection(Projection projection, String alias) { 21 this.projection = projection; 22 this.alias = alias; 23 } 24 25 public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery) 26 throws HibernateException { 27 return projection.toSqlString(criteria, position, criteriaQuery); 28 } 29 30 public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery) 31 throws HibernateException { 32 return projection.toGroupSqlString(criteria, criteriaQuery); 33 } 34 35 public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery) 36 throws HibernateException { 37 return projection.getTypes(criteria, criteriaQuery); 38 } 39 40 public String [] getColumnAliases(int loc) { 41 return projection.getColumnAliases(loc); 42 } 43 44 public Type[] getTypes(String alias, Criteria criteria, CriteriaQuery criteriaQuery) 45 throws HibernateException { 46 return this.alias.equals(alias) ? 47 getTypes(criteria, criteriaQuery) : 48 null; 49 } 50 51 public String [] getColumnAliases(String alias, int loc) { 52 return this.alias.equals(alias) ? 53 getColumnAliases(loc) : 54 null; 55 } 56 57 public String [] getAliases() { 58 return new String []{ alias }; 59 } 60 61 public boolean isGrouped() { 62 return projection.isGrouped(); 63 } 64 65 } 66 | Popular Tags |