improve some error messages
This commit is contained in:
parent
76b2f92f39
commit
e48a8120a9
|
@ -18,7 +18,6 @@ import org.hibernate.engine.spi.EntityKey;
|
|||
import org.hibernate.engine.spi.PersistenceContext;
|
||||
import org.hibernate.engine.spi.PersistentAttributeInterceptable;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.Status;
|
||||
import org.hibernate.event.spi.EventSource;
|
||||
import org.hibernate.event.spi.LoadEvent;
|
||||
import org.hibernate.event.spi.LoadEventListener;
|
||||
|
@ -65,9 +64,9 @@ public class DefaultLoadEventListener implements LoadEventListener {
|
|||
final Class<?> idClass = persister.getIdentifierType().getReturnedClass();
|
||||
if ( handleIdType( persister, event, loadType, idClass) ) {
|
||||
throw new TypeMismatchException(
|
||||
"Provided id of the wrong type for class " + persister.getEntityName()
|
||||
+ ". Expected: " + idClass
|
||||
+ ", got " + event.getEntityId().getClass()
|
||||
"Supplied id had wrong type: entity '" + persister.getEntityName()
|
||||
+ "' has id type '" + idClass
|
||||
+ "' but supplied id was of type '" + event.getEntityId().getClass() + "'"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata;
|
|||
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
|
||||
|
||||
/**
|
||||
* A JdbcValuesSource implementation for cases where we had a cache hit.
|
||||
* An {@link AbstractJdbcValues} implementation for cases where we had a cache hit.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -71,7 +71,11 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues {
|
|||
|
||||
@Override
|
||||
protected boolean processNext(RowProcessingState rowProcessingState) {
|
||||
ResultsLogger.RESULTS_MESSAGE_LOGGER.tracef( "JdbcValuesCacheHit#processNext : position = %i; numberOfRows = %i", position, numberOfRows );
|
||||
ResultsLogger.RESULTS_MESSAGE_LOGGER.tracef(
|
||||
"JdbcValuesCacheHit#processNext : position = %i; numberOfRows = %i",
|
||||
position,
|
||||
numberOfRows
|
||||
);
|
||||
|
||||
// NOTE : explicitly skipping limit handling because the cached state ought
|
||||
// already be the limited size since the cache key includes limits
|
||||
|
@ -88,7 +92,10 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues {
|
|||
|
||||
@Override
|
||||
protected boolean processPrevious(RowProcessingState rowProcessingState) {
|
||||
ResultsLogger.RESULTS_MESSAGE_LOGGER.tracef( "JdbcValuesCacheHit#processPrevious : position = %i; numberOfRows = %i", position, numberOfRows );
|
||||
ResultsLogger.RESULTS_MESSAGE_LOGGER.tracef(
|
||||
"JdbcValuesCacheHit#processPrevious : position = %i; numberOfRows = %i",
|
||||
position, numberOfRows
|
||||
);
|
||||
|
||||
// NOTE : explicitly skipping limit handling because the cached state ought
|
||||
// already be the limited size since the cache key includes limits
|
||||
|
@ -105,7 +112,10 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues {
|
|||
|
||||
@Override
|
||||
protected boolean processScroll(int numberOfRows, RowProcessingState rowProcessingState) {
|
||||
ResultsLogger.RESULTS_MESSAGE_LOGGER.tracef( "JdbcValuesCacheHit#processScroll(%i) : position = %i; numberOfRows = %i", numberOfRows, position, this.numberOfRows );
|
||||
ResultsLogger.RESULTS_MESSAGE_LOGGER.tracef(
|
||||
"JdbcValuesCacheHit#processScroll(%i) : position = %i; numberOfRows = %i",
|
||||
numberOfRows, position, this.numberOfRows
|
||||
);
|
||||
|
||||
// NOTE : explicitly skipping limit handling because the cached state should
|
||||
// already be the limited size since the cache key includes limits
|
||||
|
@ -127,7 +137,10 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues {
|
|||
|
||||
@Override
|
||||
protected boolean processPosition(int position, RowProcessingState rowProcessingState) {
|
||||
ResultsLogger.RESULTS_MESSAGE_LOGGER.tracef( "JdbcValuesCacheHit#processPosition(%i) : position = %i; numberOfRows = %i", position, this.position, this.numberOfRows );
|
||||
ResultsLogger.RESULTS_MESSAGE_LOGGER.tracef(
|
||||
"JdbcValuesCacheHit#processPosition(%i) : position = %i; numberOfRows = %i",
|
||||
position, this.position, this.numberOfRows
|
||||
);
|
||||
|
||||
// NOTE : explicitly skipping limit handling because the cached state should
|
||||
// already be the limited size since the cache key includes limits
|
||||
|
|
|
@ -10,7 +10,6 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.cache.spi.QueryKey;
|
||||
import org.hibernate.cache.spi.QueryResultsCache;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
|
@ -27,7 +26,7 @@ import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata;
|
|||
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
|
||||
|
||||
/**
|
||||
* JdbcValuesSource implementation for a JDBC ResultSet as the source
|
||||
* {@link AbstractJdbcValues} implementation for a JDBC {@link ResultSet} as the source
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -247,7 +246,7 @@ public class JdbcValuesResultSetImpl extends AbstractJdbcValues {
|
|||
|
||||
private ExecutionException makeExecutionException(String message, SQLException cause) {
|
||||
return new ExecutionException(
|
||||
message,
|
||||
message + " [" + cause.getMessage() + "]",
|
||||
executionContext.getSession().getJdbcServices().getSqlExceptionHelper().convert(
|
||||
cause,
|
||||
message
|
||||
|
@ -266,10 +265,11 @@ public class JdbcValuesResultSetImpl extends AbstractJdbcValues {
|
|||
session
|
||||
);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new HibernateException(
|
||||
"Unable to extract JDBC value for position `" + sqlSelection.getJdbcResultSetIndex() + "`",
|
||||
e
|
||||
catch ( SQLException e ) {
|
||||
// do not want to wrap in ExecutionException here
|
||||
throw executionContext.getSession().getJdbcServices().getSqlExceptionHelper().convert(
|
||||
e,
|
||||
"Could not extract column [" + sqlSelection.getJdbcResultSetIndex() + "] from JDBC ResultSet"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -293,9 +293,9 @@ public class JdbcValuesResultSetImpl extends AbstractJdbcValues {
|
|||
@Override
|
||||
public void setFetchSize(int fetchSize) {
|
||||
try {
|
||||
resultSetAccess.getResultSet().setFetchSize(fetchSize);
|
||||
resultSetAccess.getResultSet().setFetchSize( fetchSize );
|
||||
}
|
||||
catch (SQLException e) {
|
||||
catch ( SQLException e ) {
|
||||
throw makeExecutionException( "Error calling ResultSet.setFetchSize()", e );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue