HHH-14642 finish ScrollableResultsImpl
This commit is contained in:
parent
2dc07c2ffe
commit
f9534ead03
|
@ -7,7 +7,6 @@
|
|||
package org.hibernate.internal;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.sql.results.internal.RowProcessingStateStandardImpl;
|
||||
import org.hibernate.sql.results.jdbc.internal.JdbcValuesSourceProcessingStateStandardImpl;
|
||||
|
@ -85,73 +84,26 @@ public class ScrollableResultsImpl<R> extends AbstractScrollableResults<R> {
|
|||
final boolean hasResult = getRowProcessingState().last();
|
||||
prepareCurrentRow( hasResult );
|
||||
return hasResult;
|
||||
|
||||
// todo (6.0) : need these scrollable ResultSet "re-positioning"-style methods on the JdbcValues stuff
|
||||
|
||||
// try {
|
||||
// final boolean result = getResultSet().last();
|
||||
// prepareCurrentRow( result );
|
||||
// return result;
|
||||
// }
|
||||
// catch (SQLException sqle) {
|
||||
// throw convert( sqle, "could not advance using last()" );
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterLast() {
|
||||
throw new NotYetImplementedFor6Exception();
|
||||
|
||||
// todo (6.0) : need these scrollable ResultSet "re-positioning"-style methods on the JdbcValues stuff
|
||||
|
||||
// try {
|
||||
// getResultSet().afterLast();
|
||||
// }
|
||||
// catch (SQLException sqle) {
|
||||
// throw convert( sqle, "exception calling afterLast()" );
|
||||
// }
|
||||
getRowProcessingState().afterLast();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeFirst() {
|
||||
throw new NotYetImplementedFor6Exception();
|
||||
|
||||
// todo (6.0) : need these scrollable ResultSet "re-positioning"-style methods on the JdbcValues stuff
|
||||
|
||||
// try {
|
||||
// getResultSet().beforeFirst();
|
||||
// }
|
||||
// catch (SQLException sqle) {
|
||||
// throw convert( sqle, "exception calling beforeFirst()" );
|
||||
// }
|
||||
getRowProcessingState().beforeFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFirst() {
|
||||
throw new NotYetImplementedFor6Exception();
|
||||
|
||||
// todo (6.0) : need these scrollable ResultSet "re-positioning"-style methods on the JdbcValues stuff
|
||||
|
||||
// try {
|
||||
// return getResultSet().isFirst();
|
||||
// }
|
||||
// catch (SQLException sqle) {
|
||||
// throw convert( sqle, "exception calling isFirst()" );
|
||||
// }
|
||||
return getRowProcessingState().isFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLast() {
|
||||
throw new NotYetImplementedFor6Exception();
|
||||
|
||||
// todo (6.0) : need these scrollable ResultSet "re-positioning"-style methods on the JdbcValues stuff
|
||||
|
||||
// try {
|
||||
// return getResultSet().isLast();
|
||||
// }
|
||||
// catch (SQLException sqle) {
|
||||
// throw convert( sqle, "exception calling isLast()" );
|
||||
// }
|
||||
return getRowProcessingState().isLast();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -87,6 +87,18 @@ public class RowProcessingStateStandardImpl implements RowProcessingState {
|
|||
return jdbcValues.getPosition();
|
||||
}
|
||||
|
||||
public boolean isBeforeFirst() {
|
||||
return jdbcValues.isBeforeFirst( this );
|
||||
}
|
||||
|
||||
public void beforeFirst() {
|
||||
jdbcValues.beforeFirst( this );
|
||||
}
|
||||
|
||||
public boolean isFirst() {
|
||||
return jdbcValues.isFirst( this );
|
||||
}
|
||||
|
||||
public boolean first() {
|
||||
return jdbcValues.first( this );
|
||||
}
|
||||
|
@ -95,6 +107,18 @@ public class RowProcessingStateStandardImpl implements RowProcessingState {
|
|||
return jdbcValues.last( this );
|
||||
}
|
||||
|
||||
public boolean isLast() {
|
||||
return jdbcValues.isLast( this );
|
||||
}
|
||||
|
||||
public void afterLast() {
|
||||
jdbcValues.afterLast( this );
|
||||
}
|
||||
|
||||
public boolean isAfterLast() {
|
||||
return jdbcValues.isAfterLast( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getJdbcValue(int position) {
|
||||
return jdbcValues.getCurrentRowValuesArray()[ position ];
|
||||
|
|
|
@ -151,6 +151,16 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues {
|
|||
return position < 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeFirst(RowProcessingState rowProcessingState) {
|
||||
position = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFirst(RowProcessingState rowProcessingState) {
|
||||
return position == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean first(RowProcessingState rowProcessingState) {
|
||||
position = 0;
|
||||
|
@ -162,6 +172,21 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues {
|
|||
return position >= numberOfRows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterLast(RowProcessingState rowProcessingState) {
|
||||
position = numberOfRows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLast(RowProcessingState rowProcessingState) {
|
||||
if ( numberOfRows == 0 ) {
|
||||
return position == 0;
|
||||
}
|
||||
else {
|
||||
return position == numberOfRows - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean last(RowProcessingState rowProcessingState) {
|
||||
if ( numberOfRows == 0 ) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
package org.hibernate.sql.results.jdbc.internal;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.HibernateException;
|
||||
|
@ -165,7 +166,28 @@ public class JdbcValuesResultSetImpl extends AbstractJdbcValues {
|
|||
return resultSetAccess.getResultSet().isBeforeFirst();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw makeExecutionException( "Error calling ResultSet#isBeforeFirst", e );
|
||||
throw makeExecutionException( "Error calling ResultSet#isBeforeFirst()", e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeFirst(RowProcessingState rowProcessingState) {
|
||||
try {
|
||||
resultSetAccess.getResultSet().beforeFirst();
|
||||
Arrays.fill( currentRowJdbcValues, null );
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw makeExecutionException( "Error calling ResultSet#beforeFirst()", e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFirst(RowProcessingState rowProcessingState) {
|
||||
try {
|
||||
return resultSetAccess.getResultSet().isFirst();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw makeExecutionException( "Error calling ResultSet#isFirst()", e );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,7 +216,28 @@ public class JdbcValuesResultSetImpl extends AbstractJdbcValues {
|
|||
return resultSetAccess.getResultSet().isAfterLast();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw makeExecutionException( "Error calling ResultSet#isAfterLast", e );
|
||||
throw makeExecutionException( "Error calling ResultSet#isAfterLast()", e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterLast(RowProcessingState rowProcessingState) {
|
||||
try {
|
||||
resultSetAccess.getResultSet().afterLast();
|
||||
Arrays.fill( currentRowJdbcValues, null );
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw makeExecutionException( "Error calling ResultSet#afterLast()", e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLast(RowProcessingState rowProcessingState) {
|
||||
try {
|
||||
return resultSetAccess.getResultSet().isLast();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw makeExecutionException( "Error calling ResultSet#isLast()", e );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,9 +54,15 @@ public interface JdbcValues {
|
|||
int getPosition();
|
||||
|
||||
boolean isBeforeFirst(RowProcessingState rowProcessingState);
|
||||
void beforeFirst(RowProcessingState rowProcessingState);
|
||||
|
||||
boolean isFirst(RowProcessingState rowProcessingState);
|
||||
boolean first(RowProcessingState rowProcessingState);
|
||||
|
||||
boolean isAfterLast(RowProcessingState rowProcessingState);
|
||||
void afterLast(RowProcessingState rowProcessingState);
|
||||
|
||||
boolean isLast(RowProcessingState rowProcessingState);
|
||||
boolean last(RowProcessingState rowProcessingState);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue