mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-28 23:09:13 +00:00
HHH-15581 Extract skipRow and bindParameters from DeferredResultSetAccess
So that Hibernate Reactive can call them.
This commit is contained in:
parent
2f45da6e35
commit
af5ebb2a7f
@ -169,15 +169,9 @@ public boolean usesFollowOnLocking() {
|
||||
return usesFollowOnLocking;
|
||||
}
|
||||
|
||||
private void executeQuery() {
|
||||
final LogicalConnectionImplementor logicalConnection = getPersistenceContext().getJdbcCoordinator().getLogicalConnection();
|
||||
protected void bindParameters(PreparedStatement preparedStatement) throws SQLException {
|
||||
final QueryOptions queryOptions = executionContext.getQueryOptions();
|
||||
|
||||
try {
|
||||
LOG.tracef( "Executing query to retrieve ResultSet : %s", finalSql );
|
||||
// prepare the query
|
||||
preparedStatement = statementCreator.apply( finalSql );
|
||||
|
||||
// set options
|
||||
if ( queryOptions != null ) {
|
||||
if ( queryOptions.getFetchSize() != null ) {
|
||||
@ -212,6 +206,17 @@ private void executeQuery() {
|
||||
preparedStatement.setMaxRows( maxRows );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void executeQuery() {
|
||||
final LogicalConnectionImplementor logicalConnection = getPersistenceContext().getJdbcCoordinator().getLogicalConnection();
|
||||
|
||||
try {
|
||||
LOG.tracef( "Executing query to retrieve ResultSet : %s", finalSql );
|
||||
// prepare the query
|
||||
preparedStatement = statementCreator.apply( finalSql );
|
||||
|
||||
bindParameters( preparedStatement );
|
||||
|
||||
final SessionEventListenerManager eventListenerManager = executionContext.getSession()
|
||||
.getEventListenerManager();
|
||||
@ -229,6 +234,22 @@ private void executeQuery() {
|
||||
sqlStatementLogger.logSlowQuery( preparedStatement, executeStartNanos );
|
||||
}
|
||||
|
||||
skipRows( resultSet );
|
||||
logicalConnection.getResourceRegistry().register( resultSet, preparedStatement );
|
||||
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw executionContext.getSession().getJdbcServices().getSqlExceptionHelper().convert(
|
||||
e,
|
||||
"JDBC exception executing SQL [" + finalSql + "]"
|
||||
);
|
||||
}
|
||||
finally {
|
||||
logicalConnection.afterStatement();
|
||||
}
|
||||
}
|
||||
|
||||
protected void skipRows(ResultSet resultSet) throws SQLException {
|
||||
// For dialects that don't support an offset clause
|
||||
final int rowsToSkip;
|
||||
if ( !jdbcSelect.usesLimitParameters() && limit != null && limit.getFirstRow() != null && !limitHandler.supportsLimitOffset() ) {
|
||||
@ -254,18 +275,6 @@ private void executeQuery() {
|
||||
for (int i = 1; i < rowsToSkip && resultSet.next(); i++) {}
|
||||
}
|
||||
}
|
||||
logicalConnection.getResourceRegistry().register( resultSet, preparedStatement );
|
||||
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw executionContext.getSession().getJdbcServices().getSqlExceptionHelper().convert(
|
||||
e,
|
||||
"JDBC exception executing SQL [" + finalSql + "]"
|
||||
);
|
||||
}
|
||||
finally {
|
||||
logicalConnection.afterStatement();
|
||||
}
|
||||
}
|
||||
|
||||
protected ResultSet wrapResultSet(ResultSet resultSet) throws SQLException {
|
||||
|
Loading…
x
Reference in New Issue
Block a user