HHH-5765 : Wire in SQLExceptionHelper for converting SQLExceptions

This commit is contained in:
Gail Badner 2010-11-30 18:50:34 -08:00
parent 91d444423b
commit 3ca8216c7c
38 changed files with 118 additions and 200 deletions

View File

@ -32,7 +32,6 @@ import org.hibernate.cache.RegionFactory;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.JdbcSupport;
import org.hibernate.exception.SQLExceptionConverter;
import org.hibernate.hql.QueryTranslatorFactory;
import org.hibernate.jdbc.BatcherFactory;
import org.hibernate.jdbc.util.SQLStatementLogger;
@ -84,7 +83,6 @@ public final class Settings {
private TransactionManagerLookup transactionManagerLookup;
private BatcherFactory batcherFactory;
private QueryTranslatorFactory queryTranslatorFactory;
private SQLExceptionConverter sqlExceptionConverter;
private boolean wrapResultSetsEnabled;
private boolean orderUpdatesEnabled;
private boolean orderInsertsEnabled;
@ -252,10 +250,6 @@ public final class Settings {
return queryTranslatorFactory;
}
public SQLExceptionConverter getSQLExceptionConverter() {
return sqlExceptionConverter;
}
public boolean isWrapResultSetsEnabled() {
return wrapResultSetsEnabled;
}
@ -451,10 +445,6 @@ public final class Settings {
this.queryTranslatorFactory = queryTranslatorFactory;
}
void setSQLExceptionConverter(SQLExceptionConverter sqlExceptionConverter) {
this.sqlExceptionConverter = sqlExceptionConverter;
}
void setWrapResultSetsEnabled(boolean wrapResultSetsEnabled) {
this.wrapResultSetsEnabled = wrapResultSetsEnabled;
}

View File

@ -225,18 +225,6 @@ public class SettingsFactory implements Serializable {
if (useQueryCache) settings.setQueryCacheFactory( createQueryCacheFactory(properties) );
//SQL Exception converter:
SQLExceptionConverter sqlExceptionConverter;
try {
sqlExceptionConverter = SQLExceptionConverterFactory.buildSQLExceptionConverter( dialect, properties );
}
catch(HibernateException e) {
log.warn("Error building SQLExceptionConverter; using minimal converter");
sqlExceptionConverter = SQLExceptionConverterFactory.buildMinimalSQLExceptionConverter();
}
settings.setSQLExceptionConverter(sqlExceptionConverter);
//Statistics and logging:
boolean showSql = ConfigurationHelper.getBoolean(Environment.SHOW_SQL, properties);

View File

@ -111,8 +111,7 @@ public class PessimisticReadSelectLockingStrategy extends AbstractSelectLockingS
}
catch ( SQLException sqle ) {
JDBCException e = JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
JDBCException e = session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not lock: " + MessageHelper.infoString( getLockable(), id, session.getFactory() ),
sql

View File

@ -120,8 +120,7 @@ public class PessimisticReadUpdateLockingStrategy implements LockingStrategy {
}
catch ( SQLException sqle ) {
JDBCException e = JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
JDBCException e = session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not lock: " + MessageHelper.infoString( lockable, id, session.getFactory() ),
sql

View File

@ -111,8 +111,7 @@ public class PessimisticWriteSelectLockingStrategy extends AbstractSelectLocking
}
catch ( SQLException sqle ) {
JDBCException e = JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
JDBCException e = session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not lock: " + MessageHelper.infoString( getLockable(), id, session.getFactory() ),
sql

View File

@ -120,8 +120,7 @@ public class PessimisticWriteUpdateLockingStrategy implements LockingStrategy {
}
catch ( SQLException sqle ) {
JDBCException e = JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
JDBCException e = session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not lock: " + MessageHelper.infoString( lockable, id, session.getFactory() ),
sql

View File

@ -106,8 +106,7 @@ public class SelectLockingStrategy extends AbstractSelectLockingStrategy {
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
throw session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not lock: " + MessageHelper.infoString( getLockable(), id, session.getFactory() ),
sql

View File

@ -118,8 +118,7 @@ public class UpdateLockingStrategy implements LockingStrategy {
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
throw session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not lock: " + MessageHelper.infoString( lockable, id, session.getFactory() ),
sql

View File

@ -36,6 +36,7 @@ import org.hibernate.Interceptor;
import org.hibernate.MappingException;
import org.hibernate.SessionFactory;
import org.hibernate.ConnectionReleaseMode;
import org.hibernate.engine.jdbc.spi.SQLExceptionHelper;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.engine.query.QueryPlanCache;
import org.hibernate.engine.profile.FetchProfile;
@ -194,8 +195,18 @@ public interface SessionFactoryImplementor extends Mapping, SessionFactory {
* Retrieves the SQLExceptionConverter in effect for this SessionFactory.
*
* @return The SQLExceptionConverter for this SessionFactory.
*
*/
public SQLExceptionConverter getSQLExceptionConverter();
// TODO: deprecate???
/**
* Retrieves the SQLExceptionHelper in effect for this SessionFactory.
*
* @return The SQLExceptionHelper for this SessionFactory.
*
*/
public SQLExceptionHelper getSQLExceptionHelper();
public Settings getSettings();

View File

@ -61,8 +61,7 @@ public abstract class TransactionHelper {
generatedValue = doWorkInCurrentTransaction( connection, sql );
}
catch( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
throw session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not get or update next value",
sql

View File

@ -216,9 +216,8 @@ public class NativeSQLQueryPlan implements Serializable {
}
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert( session.getFactory()
.getSQLExceptionConverter(), sqle,
"could not execute native bulk manipulation query", this.sourceQuery );
throw session.getFactory().getSQLExceptionHelper().convert(
sqle, "could not execute native bulk manipulation query", this.sourceQuery );
}
return result;

View File

@ -35,6 +35,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.hibernate.HibernateException;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.jdbc.spi.SQLExceptionHelper;
import org.hibernate.exception.JDBCExceptionHelper;
import org.hibernate.exception.SQLExceptionConverter;
@ -210,16 +211,15 @@ public class Isolater {
}
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
sqlExceptionConverter(),
throw sqlExceptionHelper().convert(
sqle,
"unable to obtain isolated JDBC connection"
);
}
}
private SQLExceptionConverter sqlExceptionConverter() {
return session.getFactory().getSQLExceptionConverter();
private SQLExceptionHelper sqlExceptionHelper() {
return session.getFactory().getSQLExceptionHelper();
}
}
@ -266,8 +266,7 @@ public class Isolater {
throw ( HibernateException ) e;
}
else if ( e instanceof SQLException ) {
throw JDBCExceptionHelper.convert(
sqlExceptionConverter(),
throw sqlExceptionHelper().convert(
( SQLException ) e,
"error performing isolated work"
);
@ -294,16 +293,15 @@ public class Isolater {
}
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
sqlExceptionConverter(),
throw sqlExceptionHelper().convert(
sqle,
"unable to obtain isolated JDBC connection"
);
}
}
private SQLExceptionConverter sqlExceptionConverter() {
return session.getFactory().getSQLExceptionConverter();
private SQLExceptionHelper sqlExceptionHelper() {
return session.getFactory().getSQLExceptionHelper();
}
}
}

View File

@ -107,8 +107,7 @@ public class BasicExecutor extends AbstractStatementExecutor {
}
}
catch( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
sqle,
"could not execute update query",
sql

View File

@ -122,8 +122,7 @@ public class MultiTableDeleteExecutor extends AbstractStatementExecutor {
}
}
catch( SQLException e ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
e,
"could not insert/select ids for bulk delete",
idInsertSelect
@ -144,8 +143,7 @@ public class MultiTableDeleteExecutor extends AbstractStatementExecutor {
}
}
catch( SQLException e ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
e,
"error performing bulk delete",
deletes[i]

View File

@ -148,8 +148,7 @@ public class MultiTableUpdateExecutor extends AbstractStatementExecutor {
}
}
catch( SQLException e ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
e,
"could not insert/select ids for bulk update",
idInsertSelect
@ -179,8 +178,7 @@ public class MultiTableUpdateExecutor extends AbstractStatementExecutor {
}
}
catch( SQLException e ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
e,
"error performing bulk update",
updates[i]

View File

@ -969,8 +969,7 @@ public class QueryTranslatorImpl extends BasicLoader implements FilterTranslator
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
sqle,
"could not execute query using iterate",
getSQLString()

View File

@ -78,8 +78,7 @@ public class GUIDGenerator implements IdentifierGenerator {
}
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
throw session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not retrieve GUID",
sql

View File

@ -144,8 +144,7 @@ public class IncrementGenerator implements IdentifierGenerator, Configurable {
}
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
throw session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not fetch initial value for increment generator",
sql

View File

@ -129,8 +129,7 @@ public class SequenceGenerator implements PersistentIdentifierGenerator, Configu
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
throw session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not get next sequence value",
sql

View File

@ -130,8 +130,7 @@ public class SequenceStructure implements DatabaseStructure {
}
catch ( SQLException sqle) {
throw JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
throw session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not get next sequence value",
sql

View File

@ -61,8 +61,7 @@ public abstract class AbstractReturningDelegate implements InsertGeneratedIdenti
}
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
throw session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not insert: " + MessageHelper.infoString( persister ),
insertSQL

View File

@ -61,8 +61,7 @@ public abstract class AbstractSelectingDelegate implements InsertGeneratedIdenti
}
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
throw session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not insert: " + MessageHelper.infoString( persister ),
insertSQL
@ -90,8 +89,7 @@ public abstract class AbstractSelectingDelegate implements InsertGeneratedIdenti
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
throw session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not retrieve generated id after insert: " + MessageHelper.infoString( persister ),
insertSQL

View File

@ -122,8 +122,7 @@ public abstract class AbstractScrollableResults implements ScrollableResults {
session.getBatcher().closeQueryStatement( ps, resultSet );
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
throw session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not close results"
);

View File

@ -94,8 +94,7 @@ public class FetchingScrollableResultsImpl extends AbstractScrollableResults {
afterLast = getResultSet().isAfterLast();
}
catch( SQLException e ) {
throw JDBCExceptionHelper.convert(
getSession().getFactory().getSQLExceptionConverter(),
throw getSession().getFactory().getSQLExceptionHelper().convert(
e,
"exception calling isAfterLast()"
);
@ -209,8 +208,7 @@ public class FetchingScrollableResultsImpl extends AbstractScrollableResults {
}
}
catch( SQLException e ) {
throw JDBCExceptionHelper.convert(
getSession().getFactory().getSQLExceptionConverter(),
throw getSession().getFactory().getSQLExceptionHelper().convert(
e,
"exception calling isAfterLast()"
);
@ -244,8 +242,7 @@ public class FetchingScrollableResultsImpl extends AbstractScrollableResults {
getResultSet().beforeFirst();
}
catch( SQLException e ) {
throw JDBCExceptionHelper.convert(
getSession().getFactory().getSQLExceptionConverter(),
throw getSession().getFactory().getSQLExceptionHelper().convert(
e,
"exception calling beforeFirst()"
);
@ -328,8 +325,7 @@ public class FetchingScrollableResultsImpl extends AbstractScrollableResults {
return currentPosition == 0 && ! getResultSet().isBeforeFirst() && ! getResultSet().isAfterLast();
}
catch( SQLException e ) {
throw JDBCExceptionHelper.convert(
getSession().getFactory().getSQLExceptionConverter(),
throw getSession().getFactory().getSQLExceptionHelper().convert(
e,
"Could not determine if resultset is empty due to exception calling isBeforeFirst or isAfterLast()"
);

View File

@ -94,8 +94,7 @@ public final class IteratorImpl implements HibernateIterator {
}
catch (SQLException e) {
log.info( "Unable to close iterator", e );
throw JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
throw session.getFactory().getSQLExceptionHelper().convert(
e,
"Unable to close iterator"
);
@ -158,8 +157,7 @@ public final class IteratorImpl implements HibernateIterator {
return currentResult;
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
throw session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not get next iterator result"
);

View File

@ -70,8 +70,7 @@ public class ScrollableResultsImpl extends AbstractScrollableResults implements
return result;
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
getSession().getFactory().getSQLExceptionConverter(),
throw getSession().getFactory().getSQLExceptionHelper().convert(
sqle,
"could not advance using scroll()"
);
@ -88,8 +87,7 @@ public class ScrollableResultsImpl extends AbstractScrollableResults implements
return result;
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
getSession().getFactory().getSQLExceptionConverter(),
throw getSession().getFactory().getSQLExceptionHelper().convert(
sqle,
"could not advance using first()"
);
@ -106,8 +104,7 @@ public class ScrollableResultsImpl extends AbstractScrollableResults implements
return result;
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
getSession().getFactory().getSQLExceptionConverter(),
throw getSession().getFactory().getSQLExceptionHelper().convert(
sqle,
"could not advance using last()"
);
@ -124,8 +121,7 @@ public class ScrollableResultsImpl extends AbstractScrollableResults implements
return result;
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
getSession().getFactory().getSQLExceptionConverter(),
throw getSession().getFactory().getSQLExceptionHelper().convert(
sqle,
"could not advance using next()"
);
@ -142,8 +138,7 @@ public class ScrollableResultsImpl extends AbstractScrollableResults implements
return result;
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
getSession().getFactory().getSQLExceptionConverter(),
throw getSession().getFactory().getSQLExceptionHelper().convert(
sqle,
"could not advance using previous()"
);
@ -158,8 +153,7 @@ public class ScrollableResultsImpl extends AbstractScrollableResults implements
getResultSet().afterLast();
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
getSession().getFactory().getSQLExceptionConverter(),
throw getSession().getFactory().getSQLExceptionHelper().convert(
sqle,
"exception calling afterLast()"
);
@ -174,8 +168,7 @@ public class ScrollableResultsImpl extends AbstractScrollableResults implements
getResultSet().beforeFirst();
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
getSession().getFactory().getSQLExceptionConverter(),
throw getSession().getFactory().getSQLExceptionHelper().convert(
sqle,
"exception calling beforeFirst()"
);
@ -190,8 +183,7 @@ public class ScrollableResultsImpl extends AbstractScrollableResults implements
return getResultSet().isFirst();
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
getSession().getFactory().getSQLExceptionConverter(),
throw getSession().getFactory().getSQLExceptionHelper().convert(
sqle,
"exception calling isFirst()"
);
@ -206,8 +198,7 @@ public class ScrollableResultsImpl extends AbstractScrollableResults implements
return getResultSet().isLast();
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
getSession().getFactory().getSQLExceptionConverter(),
throw getSession().getFactory().getSQLExceptionHelper().convert(
sqle,
"exception calling isLast()"
);
@ -219,8 +210,7 @@ public class ScrollableResultsImpl extends AbstractScrollableResults implements
return getResultSet().getRow()-1;
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
getSession().getFactory().getSQLExceptionConverter(),
throw getSession().getFactory().getSQLExceptionHelper().convert(
sqle,
"exception calling getRow()"
);
@ -235,8 +225,7 @@ public class ScrollableResultsImpl extends AbstractScrollableResults implements
return result;
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
getSession().getFactory().getSQLExceptionConverter(),
throw getSession().getFactory().getSQLExceptionHelper().convert(
sqle,
"could not advance using absolute()"
);

View File

@ -75,6 +75,8 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.cfg.Settings;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.SQLExceptionHelper;
import org.hibernate.exception.SQLExceptionConverter;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.context.CurrentSessionContext;
import org.hibernate.context.JTASessionContext;
@ -94,7 +96,6 @@ import org.hibernate.engine.profile.FetchProfile;
import org.hibernate.engine.query.QueryPlanCache;
import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
import org.hibernate.event.EventListeners;
import org.hibernate.exception.SQLExceptionConverter;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.UUIDGenerator;
import org.hibernate.id.factory.IdentifierGeneratorFactory;
@ -731,7 +732,11 @@ public final class SessionFactoryImpl implements SessionFactory, SessionFactoryI
}
public SQLExceptionConverter getSQLExceptionConverter() {
return settings.getSQLExceptionConverter();
return getSQLExceptionHelper().getSqlExceptionConverter();
}
public SQLExceptionHelper getSQLExceptionHelper() {
return getJdbcServices().getSqlExceptionHelper();
}
public Set<String> getCollectionRolesByEntityParticipant(String entityName) {

View File

@ -36,7 +36,6 @@ import java.sql.Blob;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@ -1998,7 +1997,7 @@ public final class SessionImpl extends AbstractSessionImpl
jdbcContext.getConnectionManager().afterStatement();
}
catch ( SQLException e ) {
throw JDBCExceptionHelper.convert( factory.getSettings().getSQLExceptionConverter(), e, "error executing work" );
throw factory.getSQLExceptionHelper().convert( e, "error executing work" );
}
}
@ -2220,8 +2219,7 @@ public final class SessionImpl extends AbstractSessionImpl
return callback.executeOnConnection( connection );
}
catch ( SQLException e ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
e,
"Error creating contextual LOB : " + e.getMessage()
);

View File

@ -272,8 +272,7 @@ public abstract class AbstractBatcher implements Batcher {
}
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
throw factory.getSQLExceptionHelper().convert(
sqle,
"Could not execute JDBC batch update",
batchUpdateSQL
@ -587,8 +586,7 @@ public abstract class AbstractBatcher implements Batcher {
return factory.getConnectionProvider().getConnection();
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
throw factory.getSQLExceptionHelper().convert(
sqle,
"Cannot open connection"
);
@ -613,7 +611,7 @@ public abstract class AbstractBatcher implements Batcher {
factory.getConnectionProvider().closeConnection( conn );
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert( factory.getSQLExceptionConverter(), sqle, "Cannot close connection" );
throw factory.getSQLExceptionHelper().convert( sqle, "Cannot close connection" );
}
}
@ -622,8 +620,7 @@ public abstract class AbstractBatcher implements Batcher {
if (lastQuery!=null) lastQuery.cancel();
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
throw factory.getSQLExceptionHelper().convert(
sqle,
"Cannot cancel query"
);

View File

@ -446,8 +446,7 @@ public class ConnectionManager implements Serializable {
connection = factory.getConnectionProvider().getConnection();
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
throw factory.getSQLExceptionHelper().convert(
sqle,
"Cannot open connection"
);
@ -475,8 +474,7 @@ public class ConnectionManager implements Serializable {
connection = null;
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
throw factory.getSQLExceptionHelper().convert(
sqle,
"Cannot release connection"
);

View File

@ -46,7 +46,6 @@ import org.hibernate.transaction.synchronization.HibernateSynchronizationImpl;
import org.hibernate.util.JTAHelper;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.exception.JDBCExceptionHelper;
import org.hibernate.transaction.CacheSynchronization;
import org.hibernate.transaction.TransactionFactory;
/**
@ -293,8 +292,7 @@ public class JDBCContext implements Serializable, ConnectionManager.Callback {
}
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
owner.getFactory().getSQLExceptionConverter(),
throw owner.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not inspect JDBC autocommit mode"
);

View File

@ -335,8 +335,7 @@ public abstract class Loader {
);
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
throw factory.getSQLExceptionHelper().convert(
sqle,
"could not read next row of results",
getSQLString()
@ -386,8 +385,7 @@ public abstract class Loader {
while ( keyToRead.equals( loadedKeys[0] ) && resultSet.next() );
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
throw factory.getSQLExceptionHelper().convert(
sqle,
"could not doAfterTransactionCompletion sequential read of results (forward)",
getSQLString()
@ -453,8 +451,7 @@ public abstract class Loader {
return sequentialLoad( resultSet, session, queryParameters, returnProxies, currentKey );
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
throw factory.getSQLExceptionHelper().convert(
sqle,
"could not doAfterTransactionCompletion sequential read of results (forward)",
getSQLString()
@ -579,8 +576,7 @@ public abstract class Loader {
return sequentialLoad( resultSet, session, queryParameters, returnProxies, keyToRead );
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
throw factory.getSQLExceptionHelper().convert(
sqle,
"could not doAfterTransactionCompletion sequential read of results (forward)",
getSQLString()
@ -2100,8 +2096,7 @@ public abstract class Loader {
}
catch ( SQLException sqle ) {
final Loadable[] persisters = getEntityPersisters();
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
throw factory.getSQLExceptionHelper().convert(
sqle,
"could not load an entity: " +
MessageHelper.infoString( persisters[persisters.length-1], id, identifierType, getFactory() ),
@ -2143,8 +2138,7 @@ public abstract class Loader {
);
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
throw factory.getSQLExceptionHelper().convert(
sqle,
"could not collection element by index",
getSQLString()
@ -2193,8 +2187,7 @@ public abstract class Loader {
result = doQueryAndInitializeNonLazyCollections( session, qp, false );
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
throw factory.getSQLExceptionHelper().convert(
sqle,
"could not load an entity batch: " +
MessageHelper.infoString( getEntityPersisters()[0], ids, getFactory() ),
@ -2232,8 +2225,7 @@ public abstract class Loader {
);
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
throw factory.getSQLExceptionHelper().convert(
sqle,
"could not initialize a collection: " +
MessageHelper.collectionInfoString( getCollectionPersisters()[0], id, getFactory() ),
@ -2270,8 +2262,7 @@ public abstract class Loader {
);
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
throw factory.getSQLExceptionHelper().convert(
sqle,
"could not initialize a collection batch: " +
MessageHelper.collectionInfoString( getCollectionPersisters()[0], ids, getFactory() ),
@ -2303,8 +2294,7 @@ public abstract class Loader {
);
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
throw factory.getSQLExceptionHelper().convert(
sqle,
"could not load collection by subselect: " +
MessageHelper.collectionInfoString( getCollectionPersisters()[0], ids, getFactory() ),
@ -2517,8 +2507,7 @@ public abstract class Loader {
result = doQueryAndInitializeNonLazyCollections( session, queryParameters, true, forcedResultTransformer );
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
throw factory.getSQLExceptionHelper().convert(
sqle,
"could not execute query",
getSQLString()
@ -2622,8 +2611,7 @@ public abstract class Loader {
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
throw factory.getSQLExceptionHelper().convert(
sqle,
"could not execute query using scroll",
getSQLString()

View File

@ -509,8 +509,7 @@ public class QueryLoader extends BasicLoader {
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
sqle,
"could not execute query using iterate",
getSQLString()

View File

@ -54,6 +54,7 @@ import org.hibernate.engine.PersistenceContext;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.SubselectFetch;
import org.hibernate.engine.jdbc.spi.SQLExceptionHelper;
import org.hibernate.exception.JDBCExceptionHelper;
import org.hibernate.exception.SQLExceptionConverter;
import org.hibernate.id.IdentifierGenerator;
@ -177,7 +178,7 @@ public abstract class AbstractCollectionPersister
private final String entityName;
private final Dialect dialect;
private final SQLExceptionConverter sqlExceptionConverter;
private final SQLExceptionHelper sqlExceptionHelper;
private final SessionFactoryImplementor factory;
private final EntityPersister ownerPersister;
private final IdentifierGenerator identifierGenerator;
@ -236,7 +237,7 @@ public abstract class AbstractCollectionPersister
}
dialect = factory.getDialect();
sqlExceptionConverter = factory.getSQLExceptionConverter();
sqlExceptionHelper = factory.getSQLExceptionHelper();
collectionType = collection.getCollectionType();
role = collection.getRole();
entityName = collection.getOwnerEntityName();
@ -1128,8 +1129,7 @@ public abstract class AbstractCollectionPersister
}
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
sqlExceptionConverter,
throw sqlExceptionHelper.convert(
sqle,
"could not delete collection: " +
MessageHelper.collectionInfoString( this, id, getFactory() ),
@ -1240,8 +1240,7 @@ public abstract class AbstractCollectionPersister
}
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
sqlExceptionConverter,
throw sqlExceptionHelper.convert(
sqle,
"could not insert collection: " +
MessageHelper.collectionInfoString( this, id, getFactory() ),
@ -1349,8 +1348,7 @@ public abstract class AbstractCollectionPersister
}
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
sqlExceptionConverter,
throw sqlExceptionHelper.convert(
sqle,
"could not delete collection rows: " +
MessageHelper.collectionInfoString( this, id, getFactory() ),
@ -1451,8 +1449,7 @@ public abstract class AbstractCollectionPersister
}
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
sqlExceptionConverter,
throw sqlExceptionHelper.convert(
sqle,
"could not insert collection rows: " +
MessageHelper.collectionInfoString( this, id, getFactory() ),
@ -1669,8 +1666,14 @@ public abstract class AbstractCollectionPersister
return indexNodeName;
}
// TODO: deprecate???
protected SQLExceptionConverter getSQLExceptionConverter() {
return sqlExceptionConverter;
return getSQLExceptionHelper().getSqlExceptionConverter();
}
// TODO: needed???
protected SQLExceptionHelper getSQLExceptionHelper() {
return sqlExceptionHelper;
}
public CacheEntryStructure getCacheEntryStructure() {
@ -1757,8 +1760,7 @@ public abstract class AbstractCollectionPersister
}
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
sqle,
"could not retrieve collection size: " +
MessageHelper.collectionInfoString( this, key, getFactory() ),
@ -1797,8 +1799,7 @@ public abstract class AbstractCollectionPersister
}
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
sqle,
"could not check row existence: " +
MessageHelper.collectionInfoString( this, key, getFactory() ),
@ -1831,8 +1832,7 @@ public abstract class AbstractCollectionPersister
}
}
catch (SQLException sqle) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
sqle,
"could not read row: " +
MessageHelper.collectionInfoString( this, key, getFactory() ),

View File

@ -270,8 +270,7 @@ public class BasicCollectionPersister extends AbstractCollectionPersister {
return count;
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
getSQLExceptionConverter(),
throw getSQLExceptionHelper().convert(
sqle,
"could not update collection rows: " + MessageHelper.collectionInfoString( this, id, getFactory() ),
getSQLUpdateRowString()

View File

@ -306,8 +306,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
return count;
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
sqle,
"could not update collection rows: " +
MessageHelper.collectionInfoString( this, id, getFactory() ),

View File

@ -874,8 +874,7 @@ public abstract class AbstractEntityPersister
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
sqle,
"could not initialize lazy properties: " +
MessageHelper.infoString( this, id, getFactory() ),
@ -1122,8 +1121,7 @@ public abstract class AbstractEntityPersister
}
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
sqle,
"could not retrieve snapshot: " +
MessageHelper.infoString( this, id, getFactory() ),
@ -1317,8 +1315,7 @@ public abstract class AbstractEntityPersister
}
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
sqle,
"could not retrieve version: " +
MessageHelper.infoString( this, id, getFactory() ),
@ -1376,8 +1373,7 @@ public abstract class AbstractEntityPersister
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
sqle,
"could not retrieve version: " +
MessageHelper.infoString( this, id, getFactory() ),
@ -2433,8 +2429,7 @@ public abstract class AbstractEntityPersister
}
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
sqle,
"could not insert: " + MessageHelper.infoString( this ),
sql
@ -2591,8 +2586,7 @@ public abstract class AbstractEntityPersister
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
sqle,
"could not update: " + MessageHelper.infoString( this, id, getFactory() ),
sql
@ -2707,8 +2701,7 @@ public abstract class AbstractEntityPersister
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
sqle,
"could not delete: " +
MessageHelper.infoString( this, id, getFactory() ),
@ -4005,8 +3998,7 @@ public abstract class AbstractEntityPersister
}
}
catch( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
sqle,
"unable to select generated column values",
selectionSQL
@ -4101,8 +4093,7 @@ public abstract class AbstractEntityPersister
}
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
getFactory().getSQLExceptionConverter(),
throw getFactory().getSQLExceptionHelper().convert(
sqle,
"could not retrieve snapshot: " +
MessageHelper.infoString( this, id, getFactory() ),

View File

@ -104,8 +104,7 @@ public class DbTimestampType extends TimestampType {
return ts;
}
catch( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
throw session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not select current db timestamp",
timestampSelectString
@ -140,8 +139,7 @@ public class DbTimestampType extends TimestampType {
return ts;
}
catch( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
session.getFactory().getSQLExceptionConverter(),
throw session.getFactory().getSQLExceptionHelper().convert(
sqle,
"could not call current db timestamp function",
callString