Package org.hibernate.engine

Examples of org.hibernate.engine.RowSelection


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

    QueryParameters queryParametersToUse;
    if ( hasLimit && containsCollectionFetches() ) {
            LOG.firstOrMaxResultsSpecifiedWithCollectionFetch();
      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 SessionImplementor session,
      final QueryParameters queryParameters,
      final boolean returnProxies,
      final ResultTransformer forcedResultTransformer) 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 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

  public int execute(QueryParameters parameters, SessionImplementor session) throws HibernateException {

    coordinateSharedCacheCleanup( session );

    PreparedStatement st = null;
    RowSelection selection = parameters.getRowSelection();

    try {
      try {
        st = session.getTransactionCoordinator().getJdbcCoordinator().getStatementPreparer().prepareStatement( sql, false );
        Iterator parameterSpecifications = this.parameterSpecifications.iterator();
        int pos = 1;
        while ( parameterSpecifications.hasNext() ) {
          final ParameterSpecification paramSpec = ( ParameterSpecification ) parameterSpecifications.next();
          pos += paramSpec.bind( st, parameters, session, pos );
        }
        if ( selection != null ) {
          if ( selection.getTimeout() != null ) {
            st.setQueryTimeout( selection.getTimeout().intValue() );
          }
        }

        return st.executeUpdate();
      }
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

    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

  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

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.