Package org.hibernate.criterion

Examples of org.hibernate.criterion.Projection


   * @return
   */
  protected int findCriteriaRowCount(final Criteria criteria) {
    CriteriaImpl impl = (CriteriaImpl) criteria;
    // 先把Projection、ResultTransformer、OrderBy取出来,清空三者后再执行Count操作
    Projection projection = impl.getProjection();
    ResultTransformer transformer = impl.getResultTransformer();
    // 将orderBy对象中的排序字段存入数组中
    List<?> orderEntries = (List<?>) accessor.getValue(criteria);
    // 将排序字段设置为空
    accessor.setValue(Collections.emptyList(), criteria);
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

        Assert.notNull(criteria);
        Assert.isTrue(pageNo >= 1, "pageNo should be eg 1");
        Assert.isTrue(criteria instanceof CriteriaImpl);

        // 先把Projection和OrderBy条件取出来,清空两者来执行Count操作
        Projection projection = HibernateUtils.findProjection(criteria);

        List orderEntries = HibernateUtils.findOrderEntries(criteria);
        HibernateUtils.setOrderEntries(criteria, Collections.EMPTY_LIST);

        // 执行查询
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

  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

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.