public QueryParameters getQueryParameters() { final RowSelection selection = new RowSelection(); selection.setFirstRow( rootCriteria.getFirstResult() ); selection.setMaxRows( rootCriteria.getMaxResults() );
if ( needsLimit ) { LOG.needsLimit(); final RowSelection selection = new RowSelection(); selection.setFetchSize( queryParameters.getRowSelection().getFetchSize() ); selection.setTimeout( queryParameters.getRowSelection().getTimeout() );
LOG.firstOrMaxResultsSpecifiedWithCollectionFetch(); RowSelection selection = new RowSelection(); selection.setFetchSize( queryParameters.getRowSelection().getFetchSize() ); selection.setTimeout( queryParameters.getRowSelection().getTimeout() );
public AbstractQueryImpl( String queryString, 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; }
public AbstractQueryImpl( String queryString, 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; }
private int selectRecordsByMaxAge(Session session, String tempTable, Date minValue, Dialect dialect) { // fill temporary table, we don't need to join task on object on // container, oid and id is already in task table StringBuilder selectSB = new StringBuilder(); selectSB.append("select a.id as id from ").append(RAuditEventRecord.TABLE_NAME).append(" a"); selectSB.append(" where a.").append(RAuditEventRecord.COLUMN_TIMESTAMP).append(" < ###TIME###"); String selectString = selectSB.toString(); // batch size RowSelection rowSelection = new RowSelection(); rowSelection.setMaxRows(CLEANUP_AUDIT_BATCH_SIZE); LimitHandler limitHandler = dialect.getLimitHandler(); selectString = limitHandler.processSql(selectString, rowSelection); // replace ? -> batch size, $ -> ? // Sorry for that .... I just don't know how to write this query in HQL, // nor I'm not sure if limiting max size in // compound insert into ... select ... query via query.setMaxSize() // would work - TODO write more nicely if anybody knows how) selectString = selectString.replace("?", String.valueOf(CLEANUP_AUDIT_BATCH_SIZE)); selectString = selectString.replace("###TIME###", "?"); String queryString = "insert into " + tempTable + " " + selectString; LOGGER.trace("Query string = {}", queryString); NativeQuery query = session.createNativeQuery(queryString); query.setParameter(1, new Timestamp(minValue.getTime())); return query.executeUpdate(); }
RowSelection selection = new RowSelection(); selection.setFetchSize(basePage.getPageSize()); selection.setFirstRow(basePage.getBeginNumber());
RowSelection rowSelection = new RowSelection(); rowSelection.setMaxRows(recordsToDelete); LimitHandler limitHandler = dialect.getLimitHandler();
@Test public void testLimit() { RowSelection rowSelection = new RowSelection(); rowSelection.setMaxRows(getMaxRows()); long startNanos = System.nanoTime(); doInJDBC(connection -> { try (PreparedStatement statement = connection.prepareStatement(SELECT_POST_COMMENT); PreparedStatement noFixStatement = connection.prepareStatement(SELECT_POST_COMMENT_WITH_NO_FIX); ) { pocessResultSet(statement); try { pocessResultSet(noFixStatement); } catch (SQLException e) { LOGGER.error("Possible bug:", e); } } catch (SQLException e) { fail(e.getMessage()); } }); LOGGER.info("{} Result Set with limit took {} millis", dataSourceProvider().database(), TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanos)); }
public QueryParameters getQueryParameters() { LockOptions lockOptions = new LockOptions(); RowSelection selection = new RowSelection(); selection.setFirstRow( rootCriteria.getFirstResult() ); selection.setMaxRows( rootCriteria.getMaxResults() );
public QueryParameters getQueryParameters() { LockOptions lockOptions = new LockOptions(); RowSelection selection = new RowSelection(); selection.setFirstRow( rootCriteria.getFirstResult() ); selection.setMaxRows( rootCriteria.getMaxResults() );
@Test public void testLimit() { RowSelection rowSelection = new RowSelection(); rowSelection.setMaxRows(getMaxRows()); long startNanos = System.nanoTime(); doInJDBC(connection -> { try (PreparedStatement statement = connection.prepareStatement(SELECT_POST) ) { statement.setMaxRows(getMaxRows()); assertEquals(getMaxRows(), processResultSet(statement)); } catch (SQLException e) { fail(e.getMessage()); } }); LOGGER.info("{} Result Set with limit took {} millis", dataSourceProvider().database(), TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanos)); }
@Test public void testLimit() { final RowSelection rowSelection = new RowSelection(); rowSelection.setMaxRows(getMaxRows()); LimitHandler limitHandler = ((SessionFactoryImpl) sessionFactory()).getDialect().getLimitHandler(); String limitStatement = limitHandler.processSql(SELECT_POST_COMMENT, rowSelection); long startNanos = System.nanoTime(); doInJDBC(connection -> { try (PreparedStatement statement = connection.prepareStatement(limitStatement)) { limitHandler.bindLimitParametersAtEndOfQuery(rowSelection, statement, 1); statement.setInt(1, getMaxRows()); statement.execute(); int count = 0; ResultSet resultSet = statement.getResultSet(); while (resultSet.next()) { resultSet.getLong(1); count++; } assertEquals(getMaxRows(), count); } catch (SQLException e) { fail(e.getMessage()); } }); LOGGER.info("{} Result Set with limit took {} millis", dataSourceProvider().database(), TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanos)); }
RowSelection selection = new RowSelection(); selection.setFetchSize( queryParameters.getRowSelection().getFetchSize() ); selection.setTimeout( queryParameters.getRowSelection().getTimeout() );
if ( needsLimit ) { LOG.needsLimit(); RowSelection selection = new RowSelection(); selection.setFetchSize( queryParameters.getRowSelection().getFetchSize() ); selection.setTimeout( queryParameters.getRowSelection().getTimeout() );
if ( needsLimit ) { LOG.needsLimit(); RowSelection selection = new RowSelection(); selection.setFetchSize( queryParameters.getRowSelection().getFetchSize() ); selection.setTimeout( queryParameters.getRowSelection().getTimeout() );
if ( hasLimit && containsCollectionFetches() ) { LOG.firstOrMaxResultsSpecifiedWithCollectionFetch(); RowSelection selection = new RowSelection(); selection.setFetchSize( queryParameters.getRowSelection().getFetchSize() ); selection.setTimeout( queryParameters.getRowSelection().getTimeout() );
@SuppressWarnings("unchecked") @Override public final List<Long> list( SessionImplementor session, QueryParameters queryParameters) throws HibernateException { boolean hasLimit = queryParameters.getRowSelection() != null && queryParameters.getRowSelection().definesLimits(); if (hasLimit) { RowSelection selection = new RowSelection(); selection.setFetchSize( queryParameters.getRowSelection().getFetchSize() ); selection.setTimeout( queryParameters.getRowSelection().getTimeout() ); queryParameters = queryParameters.createCopyUsing(selection); } return super.list(session, queryParameters); }
@Test public void testLimit() { RowSelection rowSelection = new RowSelection(); rowSelection.setMaxRows(getMaxRows()); long startNanos = System.nanoTime(); doInJDBC(connection -> { try (PreparedStatement statement1 = connection.prepareStatement(SELECT_POST_COMMENT_1); PreparedStatement statement11 = connection.prepareStatement(SELECT_POST_COMMENT_1); PreparedStatement statement2 = connection.prepareStatement(SELECT_POST_COMMENT_2); ) { statement1.setMaxRows(getMaxRows()); assertEquals(getMaxRows(), processResultSet(statement1)); assertEquals(getPostCommentCount() * getPostCount(), processResultSet(statement11)); assertEquals(getPostCommentCount() * getPostCount(), processResultSet(statement2)); } catch (SQLException e) { fail(e.getMessage()); } }); LOGGER.info("{} Result Set with limit took {} millis", dataSourceProvider().database(), TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanos)); }
if ( hasLimit && containsCollectionFetches() ) { LOG.firstOrMaxResultsSpecifiedWithCollectionFetch(); RowSelection selection = new RowSelection(); selection.setFetchSize( queryParameters.getRowSelection().getFetchSize() ); selection.setTimeout( queryParameters.getRowSelection().getTimeout() );