Package org.hibernate.engine

Examples of org.hibernate.engine.RowSelection


  private List doQuery(
      final SessionImplementor session,
      final QueryParameters queryParameters,
      final boolean returnProxies) throws SQLException, HibernateException {

    final RowSelection selection = queryParameters.getRowSelection();
    final int maxRows = hasMaxRows( selection ) ?
        selection.getMaxRows().intValue() :
        Integer.MAX_VALUE;

    final int entitySpan = getEntityPersisters().length;

    final ArrayList hydratedObjects = entitySpan == 0 ? null : new ArrayList( entitySpan * 10 );
View Full Code Here


          final SessionImplementor session) throws SQLException, HibernateException {

    queryParameters.processFilters( getSQLString(), session );
    String sql = queryParameters.getFilteredSQL();
    final Dialect dialect = getFactory().getDialect();
    final RowSelection selection = queryParameters.getRowSelection();
    boolean useLimit = useLimit( selection, dialect );
    boolean hasFirstRow = getFirstRow( selection ) > 0;
    boolean useOffset = hasFirstRow && useLimit && dialect.supportsLimitOffset();
    boolean callable = queryParameters.isCallable();
   
    boolean useScrollableResultSetToSkip = hasFirstRow &&
        !useOffset &&
        getFactory().getSettings().isScrollableResultSetsEnabled();
    ScrollMode scrollMode = scroll ? queryParameters.getScrollMode() : ScrollMode.SCROLL_INSENSITIVE;

    if ( useLimit ) {
      sql = dialect.getLimitString(
          sql.trim(), //use of trim() here is ugly?
          useOffset ? getFirstRow(selection) : 0,
          getMaxOrLimit(selection, dialect)
        );
    }

    sql = preprocessSQL( sql, queryParameters, dialect );
   
    PreparedStatement st = null;
   
    if (callable) {
      st = session.getBatcher()
        .prepareCallableQueryStatement( sql, scroll || useScrollableResultSetToSkip, scrollMode );
    }
    else {
      st = session.getBatcher()
        .prepareQueryStatement( sql, scroll || useScrollableResultSetToSkip, scrollMode );
    }
       

    try {

      int col = 1;
      //TODO: can we limit stored procedures ?!
      if ( useLimit && dialect.bindLimitParametersFirst() ) {
        col += bindLimitParameters( st, col, selection );
      }
      if (callable) {
        col = dialect.registerResultSetOutParameter( (CallableStatement)st, col );
      }

      col += bindParameterValues( st, queryParameters, col, session );

      if ( useLimit && !dialect.bindLimitParametersFirst() ) {
        col += bindLimitParameters( st, col, selection );
      }

      if ( !useLimit ) {
        setMaxRows( st, selection );
      }

      if ( selection != null ) {
        if ( selection.getTimeout() != null ) {
          st.setQueryTimeout( selection.getTimeout().intValue() );
        }
        if ( selection.getFetchSize() != null ) {
          st.setFetchSize( selection.getFetchSize().intValue() );
        }
      }

      // handle lock timeout...
      LockOptions lockOptions = queryParameters.getLockOptions();
View Full Code Here

    return rootCriteria;
  }

  public QueryParameters getQueryParameters() {
    LockOptions lockOptions = new LockOptions();
    RowSelection selection = new RowSelection();
    selection.setFirstRow( rootCriteria.getFirstResult() );
    selection.setMaxRows( rootCriteria.getMaxResults() );
    selection.setTimeout( rootCriteria.getTimeout() );
    selection.setFetchSize( rootCriteria.getFetchSize() );

    Iterator iter = rootCriteria.getLockModes().entrySet().iterator();
    while ( iter.hasNext() ) {
      Map.Entry me = ( Map.Entry ) iter.next();
      final Criteria subcriteria = getAliasedCriteria( ( String ) me.getKey() );
View Full Code Here

    boolean needsDistincting = ( query.getSelectClause().isDistinct() || hasLimit ) && containsCollectionFetches();

    QueryParameters queryParametersToUse;
    if ( hasLimit && containsCollectionFetches() ) {
      log.warn( "firstResult/maxResults specified with collection fetch; applying in memory!" );
      RowSelection selection = new RowSelection();
      selection.setFetchSize( queryParameters.getRowSelection().getFetchSize() );
      selection.setTimeout( queryParameters.getRowSelection().getTimeout() );
      queryParametersToUse = queryParameters.createCopyUsing( selection );
    }
    else {
      queryParametersToUse = queryParameters;
    }
View Full Code Here

          FlushMode flushMode,
          SessionImplementor session,
          ParameterMetadata parameterMetadata) {
    this.session = session;
    this.queryString = queryString;
    this.selection = new RowSelection();
    this.flushMode = flushMode;
    this.cacheMode = null;
    this.parameterMetadata = parameterMetadata;
  }
View Full Code Here

                       queryParameters.getRowSelection().definesLimits();
    boolean needsLimit = hasLimit && translators.length > 1;
    QueryParameters queryParametersToUse;
    if ( needsLimit ) {
      log.warn( "firstResult/maxResults specified on polymorphic query; applying in memory!" );
      RowSelection selection = new RowSelection();
      selection.setFetchSize( queryParameters.getRowSelection().getFetchSize() );
      selection.setTimeout( queryParameters.getRowSelection().getTimeout() );
      queryParametersToUse = queryParameters.createCopyUsing( selection );
    }
    else {
      queryParametersToUse = queryParameters;
    }
View Full Code Here

    boolean needsDistincting = ( query.getSelectClause().isDistinct() || hasLimit ) && containsCollectionFetches();

    QueryParameters queryParametersToUse;
    if ( hasLimit && containsCollectionFetches() ) {
      log.warn( "firstResult/maxResults specified with collection fetch; applying in memory!" );
      RowSelection selection = new RowSelection();
      selection.setFetchSize( queryParameters.getRowSelection().getFetchSize() );
      selection.setTimeout( queryParameters.getRowSelection().getTimeout() );
      queryParametersToUse = queryParameters.createCopyUsing( selection );
    }
    else {
      queryParametersToUse = queryParameters;
    }
View Full Code Here

  private List doQuery(
      final SessionImplementor session,
      final QueryParameters queryParameters,
      final boolean returnProxies) throws SQLException, HibernateException {

    final RowSelection selection = queryParameters.getRowSelection();
    final int maxRows = hasMaxRows( selection ) ?
        selection.getMaxRows().intValue() :
        Integer.MAX_VALUE;

    final int entitySpan = getEntityPersisters().length;

    final ArrayList hydratedObjects = entitySpan == 0 ? null : new ArrayList( entitySpan * 10 );
View Full Code Here

          final SessionImplementor session) throws SQLException, HibernateException {

    queryParameters.processFilters( getSQLString(), session );
    String sql = queryParameters.getFilteredSQL();
    final Dialect dialect = getFactory().getDialect();
    final RowSelection selection = queryParameters.getRowSelection();
    boolean useLimit = useLimit( selection, dialect );
    boolean hasFirstRow = getFirstRow( selection ) > 0;
    boolean useOffset = hasFirstRow && useLimit && dialect.supportsLimitOffset();
    boolean callable = queryParameters.isCallable();
   
    boolean useScrollableResultSetToSkip = hasFirstRow &&
        !useOffset &&
        getFactory().getSettings().isScrollableResultSetsEnabled();
    ScrollMode scrollMode = scroll ? queryParameters.getScrollMode() : ScrollMode.SCROLL_INSENSITIVE;

    if ( useLimit ) {
      sql = dialect.getLimitString(
          sql.trim(), //use of trim() here is ugly?
          useOffset ? getFirstRow(selection) : 0,
          getMaxOrLimit(selection, dialect)
        );
    }

    sql = preprocessSQL( sql, queryParameters, dialect );
   
    PreparedStatement st = null;
   
    if (callable) {
      st = session.getBatcher()
        .prepareCallableQueryStatement( sql, scroll || useScrollableResultSetToSkip, scrollMode );
    }
    else {
      st = session.getBatcher()
        .prepareQueryStatement( sql, scroll || useScrollableResultSetToSkip, scrollMode );
    }
       

    try {

      int col = 1;
      //TODO: can we limit stored procedures ?!
      if ( useLimit && dialect.bindLimitParametersFirst() ) {
        col += bindLimitParameters( st, col, selection );
      }
      if (callable) {
        col = dialect.registerResultSetOutParameter( (CallableStatement)st, col );
      }

      col += bindParameterValues( st, queryParameters, col, session );

      if ( useLimit && !dialect.bindLimitParametersFirst() ) {
        col += bindLimitParameters( st, col, selection );
      }

      if ( !useLimit ) {
        setMaxRows( st, selection );
      }

      if ( selection != null ) {
        if ( selection.getTimeout() != null ) {
          st.setQueryTimeout( selection.getTimeout().intValue() );
        }
        if ( selection.getFetchSize() != null ) {
          st.setFetchSize( selection.getFetchSize().intValue() );
        }
      }
    }
    catch ( SQLException sqle ) {
      session.getBatcher().closeQueryStatement( st, null );
View Full Code Here

        );
      }
    }

    // decode row selection...
    final RowSelection selection = queryParameters.getRowSelection();
    final Integer firstRow;
    final Integer maxRows;
    if ( selection != null ) {
      firstRow = selection.getFirstRow();
      maxRows = selection.getMaxRows();
    }
    else {
      firstRow = null;
      maxRows = null;
    }
View Full Code Here

TOP

Related Classes of org.hibernate.engine.RowSelection

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.