Package org.hibernate.engine.spi

Examples of org.hibernate.engine.spi.RowSelection


          final QueryParameters queryParameters,
          final LimitHandler limitHandler,
          final boolean scroll,
          final SessionImplementor session) throws SQLException, HibernateException {
    final Dialect dialect = getFactory().getDialect();
    final RowSelection selection = queryParameters.getRowSelection();
    boolean useLimit = LimitHelper.useLimit( limitHandler, selection );
    boolean hasFirstRow = LimitHelper.hasFirstRow( selection );
    boolean useLimitOffset = hasFirstRow && useLimit && limitHandler.supportsLimitOffset();
    boolean callable = queryParameters.isCallable();
    final ScrollMode scrollMode = getScrollMode( scroll, hasFirstRow, useLimitOffset, queryParameters );
   
    PreparedStatement st = session.getTransactionCoordinator().getJdbcCoordinator().getStatementPreparer().prepareQueryStatement(
        sql,
        callable,
        scrollMode
    );

    try {

      int col = 1;
      //TODO: can we limit stored procedures ?!
      col += limitHandler.bindLimitParametersAtStartOfQuery( st, col );

      if (callable) {
        col = dialect.registerResultSetOutParameter( (CallableStatement)st, col );
      }

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

      col += limitHandler.bindLimitParametersAtEndOfQuery( st, col );

      limitHandler.setMaxRows( st );

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

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


      final QueryParameters queryParameters,
      final LimitHandler limitHandler,
      final boolean scroll,
      final SessionImplementor session) throws SQLException, HibernateException {
    final Dialect dialect = getFactory().getDialect();
    final RowSelection selection = queryParameters.getRowSelection();
    final boolean useLimit = LimitHelper.useLimit( limitHandler, selection );
    final boolean hasFirstRow = LimitHelper.hasFirstRow( selection );
    final boolean useLimitOffset = hasFirstRow && useLimit && limitHandler.supportsLimitOffset();
    final boolean callable = queryParameters.isCallable();
    final ScrollMode scrollMode = getScrollMode( scroll, hasFirstRow, useLimitOffset, queryParameters );

    final PreparedStatement st = session.getTransactionCoordinator().getJdbcCoordinator()
        .getStatementPreparer().prepareQueryStatement( sql, callable, scrollMode );

    try {

      int col = 1;
      //TODO: can we limit stored procedures ?!
      col += limitHandler.bindLimitParametersAtStartOfQuery( st, col );

      if (callable) {
        col = dialect.registerResultSetOutParameter( (CallableStatement)st, col );
      }

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

      col += limitHandler.bindLimitParametersAtEndOfQuery( st, col );

      limitHandler.setMaxRows( st );

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

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

      List<AfterLoadAction> afterLoadActionList) throws SQLException {

    handlePotentiallyEmptyCollectionRootReturns( loadPlan, queryParameters.getCollectionKeys(), resultSet, session );

    final int maxRows;
    final RowSelection selection = queryParameters.getRowSelection();
    if ( LimitHelper.hasMaxRows( selection ) ) {
      maxRows = selection.getMaxRows();
      LOG.tracef( "Limiting ResultSet processing to just %s rows", maxRows );
    }
    else {
      maxRows = Integer.MAX_VALUE;
    }
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 useLimitOffset = hasFirstRow && useLimit && dialect.supportsLimitOffset();
    boolean callable = queryParameters.isCallable();

    final boolean canScroll = getFactory().getSettings().isScrollableResultSetsEnabled();
    final boolean useScrollableResultSetToSkip = hasFirstRow &&
        !useLimitOffset && canScroll;
    final ScrollMode scrollMode = getScrollMode( scroll, hasFirstRow, useLimit, queryParameters );
//
//    if(canScroll && ( scroll || useScrollableResultSetToSkip )){
//       scrollMode = scroll ? queryParameters.getScrollMode() : ScrollMode.SCROLL_INSENSITIVE;
//    }else{
//      scrollMode = null;
//    }
    if ( useLimit ) {
      sql = dialect.getLimitString(
          sql.trim(), //use of trim() here is ugly?
          useLimitOffset ? getFirstRow(selection) : 0,
          getMaxOrLimit(selection, dialect)
        );
    }

    sql = preprocessSQL( sql, queryParameters, dialect );

    PreparedStatement st = null;


    st = session.getTransactionCoordinator().getJdbcCoordinator().getStatementPreparer().prepareQueryStatement(
        sql,
        callable,
        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

          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

      List<AfterLoadAction> afterLoadActionList) throws SQLException {

    handlePotentiallyEmptyCollectionRootReturns( loadPlan, queryParameters.getCollectionKeys(), resultSet, session );

    final int maxRows;
    final RowSelection selection = queryParameters.getRowSelection();
    if ( LimitHelper.hasMaxRows( selection ) ) {
      maxRows = selection.getMaxRows();
      LOG.tracef( "Limiting ResultSet processing to just %s rows", maxRows );
    }
    else {
      maxRows = Integer.MAX_VALUE;
    }
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() );
    final Map<String, LockMode> lockModeMap = rootCriteria.getLockModes();
    for ( final String key : lockModeMap.keySet() ) {
      final Criteria subcriteria = getAliasedCriteria( key );
      lockOptions.setAliasSpecificLockMode( getSQLAlias( subcriteria ), lockModeMap.get( key ) );
    }
View Full Code Here

    final boolean needsLimit = hasLimit && translators.length > 1;

    final QueryParameters queryParametersToUse;
    if ( needsLimit ) {
      LOG.needsLimit();
      final 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

      final QueryParameters queryParameters,
      final LimitHandler limitHandler,
      final boolean scroll,
      final SessionImplementor session) throws SQLException, HibernateException {
    final Dialect dialect = getFactory().getDialect();
    final RowSelection selection = queryParameters.getRowSelection();
    final boolean useLimit = LimitHelper.useLimit( limitHandler, selection );
    final boolean hasFirstRow = LimitHelper.hasFirstRow( selection );
    final boolean useLimitOffset = hasFirstRow && useLimit && limitHandler.supportsLimitOffset();
    final boolean callable = queryParameters.isCallable();
    final ScrollMode scrollMode = getScrollMode( scroll, hasFirstRow, useLimitOffset, queryParameters );

    final PreparedStatement st = session.getTransactionCoordinator().getJdbcCoordinator()
        .getStatementPreparer().prepareQueryStatement( sql, callable, scrollMode );

    try {

      int col = 1;
      //TODO: can we limit stored procedures ?!
      col += limitHandler.bindLimitParametersAtStartOfQuery( st, col );

      if (callable) {
        col = dialect.registerResultSetOutParameter( (CallableStatement)st, col );
      }

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

      col += limitHandler.bindLimitParametersAtEndOfQuery( st, col );

      limitHandler.setMaxRows( st );

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

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

      List<AfterLoadAction> afterLoadActionList) throws SQLException {

    handlePotentiallyEmptyCollectionRootReturns( loadPlan, queryParameters.getCollectionKeys(), resultSet, session );

    final int maxRows;
    final RowSelection selection = queryParameters.getRowSelection();
    if ( LimitHelper.hasMaxRows( selection ) ) {
      maxRows = selection.getMaxRows();
      LOG.tracef( "Limiting ResultSet processing to just %s rows", maxRows );
    }
    else {
      maxRows = Integer.MAX_VALUE;
    }
View Full Code Here

TOP

Related Classes of org.hibernate.engine.spi.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.