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.PersistenceContext;
|
||||||
import org.hibernate.engine.spi.PersistentAttributeInterceptable;
|
import org.hibernate.engine.spi.PersistentAttributeInterceptable;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
import org.hibernate.engine.spi.Status;
|
|
||||||
import org.hibernate.event.spi.EventSource;
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.event.spi.LoadEvent;
|
import org.hibernate.event.spi.LoadEvent;
|
||||||
import org.hibernate.event.spi.LoadEventListener;
|
import org.hibernate.event.spi.LoadEventListener;
|
||||||
|
@ -65,9 +64,9 @@ public class DefaultLoadEventListener implements LoadEventListener {
|
||||||
final Class<?> idClass = persister.getIdentifierType().getReturnedClass();
|
final Class<?> idClass = persister.getIdentifierType().getReturnedClass();
|
||||||
if ( handleIdType( persister, event, loadType, idClass) ) {
|
if ( handleIdType( persister, event, loadType, idClass) ) {
|
||||||
throw new TypeMismatchException(
|
throw new TypeMismatchException(
|
||||||
"Provided id of the wrong type for class " + persister.getEntityName()
|
"Supplied id had wrong type: entity '" + persister.getEntityName()
|
||||||
+ ". Expected: " + idClass
|
+ "' has id type '" + idClass
|
||||||
+ ", got " + event.getEntityId().getClass()
|
+ "' 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;
|
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
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
@ -71,7 +71,11 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean processNext(RowProcessingState rowProcessingState) {
|
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
|
// NOTE : explicitly skipping limit handling because the cached state ought
|
||||||
// already be the limited size since the cache key includes limits
|
// already be the limited size since the cache key includes limits
|
||||||
|
@ -88,7 +92,10 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean processPrevious(RowProcessingState rowProcessingState) {
|
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
|
// NOTE : explicitly skipping limit handling because the cached state ought
|
||||||
// already be the limited size since the cache key includes limits
|
// already be the limited size since the cache key includes limits
|
||||||
|
@ -105,7 +112,10 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean processScroll(int numberOfRows, RowProcessingState rowProcessingState) {
|
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
|
// NOTE : explicitly skipping limit handling because the cached state should
|
||||||
// already be the limited size since the cache key includes limits
|
// already be the limited size since the cache key includes limits
|
||||||
|
@ -127,7 +137,10 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean processPosition(int position, RowProcessingState rowProcessingState) {
|
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
|
// NOTE : explicitly skipping limit handling because the cached state should
|
||||||
// already be the limited size since the cache key includes limits
|
// 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.sql.SQLException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
|
||||||
import org.hibernate.cache.spi.QueryKey;
|
import org.hibernate.cache.spi.QueryKey;
|
||||||
import org.hibernate.cache.spi.QueryResultsCache;
|
import org.hibernate.cache.spi.QueryResultsCache;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
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;
|
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
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
@ -247,7 +246,7 @@ public class JdbcValuesResultSetImpl extends AbstractJdbcValues {
|
||||||
|
|
||||||
private ExecutionException makeExecutionException(String message, SQLException cause) {
|
private ExecutionException makeExecutionException(String message, SQLException cause) {
|
||||||
return new ExecutionException(
|
return new ExecutionException(
|
||||||
message,
|
message + " [" + cause.getMessage() + "]",
|
||||||
executionContext.getSession().getJdbcServices().getSqlExceptionHelper().convert(
|
executionContext.getSession().getJdbcServices().getSqlExceptionHelper().convert(
|
||||||
cause,
|
cause,
|
||||||
message
|
message
|
||||||
|
@ -266,10 +265,11 @@ public class JdbcValuesResultSetImpl extends AbstractJdbcValues {
|
||||||
session
|
session
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch ( SQLException e ) {
|
||||||
throw new HibernateException(
|
// do not want to wrap in ExecutionException here
|
||||||
"Unable to extract JDBC value for position `" + sqlSelection.getJdbcResultSetIndex() + "`",
|
throw executionContext.getSession().getJdbcServices().getSqlExceptionHelper().convert(
|
||||||
e
|
e,
|
||||||
|
"Could not extract column [" + sqlSelection.getJdbcResultSetIndex() + "] from JDBC ResultSet"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,9 +293,9 @@ public class JdbcValuesResultSetImpl extends AbstractJdbcValues {
|
||||||
@Override
|
@Override
|
||||||
public void setFetchSize(int fetchSize) {
|
public void setFetchSize(int fetchSize) {
|
||||||
try {
|
try {
|
||||||
resultSetAccess.getResultSet().setFetchSize(fetchSize);
|
resultSetAccess.getResultSet().setFetchSize( fetchSize );
|
||||||
}
|
}
|
||||||
catch (SQLException e) {
|
catch ( SQLException e ) {
|
||||||
throw makeExecutionException( "Error calling ResultSet.setFetchSize()", e );
|
throw makeExecutionException( "Error calling ResultSet.setFetchSize()", e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue