Package org.hibernate.criterion

Examples of org.hibernate.criterion.Projection


  public Type getTypeUsingProjection(Criteria subcriteria, String propertyName)
      throws HibernateException {

    //first look for a reference to a projection alias
    final Projection projection = rootCriteria.getProjection();
    Type[] projectionTypes = projection == null ?
                             null :
                             projection.getTypes( propertyName, subcriteria, this );

    if ( projectionTypes == null ) {
      try {
        //it does not refer to an alias of a projection,
        //look for a property
View Full Code Here


  public String[] getColumnsUsingProjection(
      Criteria subcriteria,
          String propertyName) throws HibernateException {

    //first look for a reference to a projection alias
    final Projection projection = rootCriteria.getProjection();
    String[] projectionColumns = null;
    if ( projection != null ) {
      projectionColumns = ( projection instanceof EnhancedProjection ?
          ( ( EnhancedProjection ) projection ).getColumnAliases( propertyName, 0, rootCriteria, this ) :
          projection.getColumnAliases( propertyName, 0 )
      );
    }
    if ( projectionColumns == null ) {
      //it does not refer to an alias of a projection,
      //look for a property
View Full Code Here

  public Type getTypeUsingProjection(Criteria subcriteria, String propertyName)
      throws HibernateException {

    //first look for a reference to a projection alias
    final Projection projection = rootCriteria.getProjection();
    Type[] projectionTypes = projection == null ?
                             null :
                             projection.getTypes( propertyName, subcriteria, this );

    if ( projectionTypes == null ) {
      try {
        //it does not refer to an alias of a projection,
        //look for a property
View Full Code Here

          .add( Projections.property("c.courseCode") )
          .add( Projections.property("c.description") )
        )
      .uniqueResult();
     
    Projection p1 = Projections.projectionList()
      .add( Projections.count("studentNumber") )
      .add( Projections.max("studentNumber") )
      .add( Projections.rowCount() );
   
    Projection p2 = Projections.projectionList()
      .add( Projections.min("studentNumber") )
      .add( Projections.avg("studentNumber") )
      .add( Projections.sqlProjection(
          "1 as constOne, count(*) as countStar",
          new String[] { "constOne", "countStar" },
View Full Code Here

          .add( Property.forName("c.courseCode") )
          .add( Property.forName("c.description") )
        )
      .uniqueResult();
     
    Projection p1 = Projections.projectionList()
      .add( Property.forName("studentNumber").count() )
      .add( Property.forName("studentNumber").max() )
      .add( Projections.rowCount() );
   
    Projection p2 = Projections.projectionList()
      .add( Property.forName("studentNumber").min() )
      .add( Property.forName("studentNumber").avg() )
      .add( Projections.sqlProjection(
          "1 as constOne, count(*) as countStar",
          new String[] { "constOne", "countStar" },
View Full Code Here

  @SuppressWarnings({ "unchecked", "rawtypes" })
  protected long countCriteriaResult(final Criteria c) {
    CriteriaImpl impl = (CriteriaImpl) c;

    // 先把Projection、ResultTransformer、OrderBy取出来,清空三者后再执行Count操作
    Projection projection = impl.getProjection();
    ResultTransformer transformer = impl.getResultTransformer();

    List<CriteriaImpl.OrderEntry> orderEntries = null;
    try {
      orderEntries = (List<OrderEntry>) ReflectionUtils.getFieldValue(impl,"orderEntries");
View Full Code Here

    List<T> targetList = null;
    if (null == criteriaImpl.getProjection()) {
      criteria.setFirstResult((limit.getPageNo() - 1) * limit.getPageSize()).setMaxResults(
          limit.getPageSize());
      targetList = criteria.list();
      Projection projection = null;
      criteria.setFirstResult(0).setMaxResults(1);
      projection = Projections.rowCount();
      totalCount = ((Integer) criteria.setProjection(projection).uniqueResult()).intValue();
    } else {
      List<T> list = criteria.list();
View Full Code Here

    List<?> targetList = null;
    if (null == criteriaImpl.getProjection()) {
      criteria.setFirstResult((limit.getPageNo() - 1) * limit.getPageSize()).setMaxResults(
          limit.getPageSize());
      targetList = criteria.list();
      Projection projection = null;
      criteria.setFirstResult(0).setMaxResults(1);
      projection = Projections.rowCount();
      totalCount = ((Integer) criteria.setProjection(projection).uniqueResult()).intValue();
    } else {
      List<?> list = criteria.list();
View Full Code Here

    List<T> targetList = null;
    if (null == criteriaImpl.getProjection()) {
      criteria.setFirstResult((limit.getPageNo() - 1) * limit.getPageSize()).setMaxResults(
          limit.getPageSize());
      targetList = criteria.list();
      Projection projection = null;
      criteria.setFirstResult(0).setMaxResults(1);
      projection = Projections.rowCount();
      totalCount = ((Number) criteria.setProjection(projection).uniqueResult()).intValue();
    } else {
      List<T> list = criteria.list();
View Full Code Here

    List<?> targetList = null;
    if (null == criteriaImpl.getProjection()) {
      criteria.setFirstResult((limit.getPageNo() - 1) * limit.getPageSize()).setMaxResults(
          limit.getPageSize());
      targetList = criteria.list();
      Projection projection = null;
      criteria.setFirstResult(0).setMaxResults(1);
      projection = Projections.rowCount();
      totalCount = ((Integer) criteria.setProjection(projection).uniqueResult()).intValue();
    } else {
      List<?> list = criteria.list();
View Full Code Here

TOP

Related Classes of org.hibernate.criterion.Projection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.