HHH-5781 - Refactor code in org.hibernate.jdbc to spi/internal and remove obsolete code

This commit is contained in:
Steve Ebersole 2011-03-05 08:06:21 -06:00
parent 21cc90fbf4
commit 73e85ee761
36 changed files with 120 additions and 299 deletions

View File

@ -29,7 +29,6 @@ import org.hibernate.cache.QueryCacheFactory;
import org.hibernate.cache.RegionFactory;
import org.hibernate.engine.jdbc.JdbcSupport;
import org.hibernate.hql.QueryTranslatorFactory;
import org.hibernate.jdbc.util.SQLStatementLogger;
import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.tuple.entity.EntityTuplizerFactory;
@ -42,9 +41,6 @@ import java.util.Map;
*/
public final class Settings {
// private boolean showSql;
// private boolean formatSql;
private SQLStatementLogger sqlStatementLogger;
private Integer maximumFetchDepth;
private Map querySubstitutions;
private int jdbcBatchSize;
@ -99,14 +95,6 @@ public final class Settings {
// public getters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// public boolean isShowSqlEnabled() {
// return showSql;
// }
//
// public boolean isFormatSqlEnabled() {
// return formatSql;
// }
public String getImportFiles() {
return importFiles;
}
@ -115,10 +103,6 @@ public final class Settings {
this.importFiles = importFiles;
}
public SQLStatementLogger getSqlStatementLogger() {
return sqlStatementLogger;
}
public String getDefaultSchemaName() {
return defaultSchemaName;
}
@ -282,18 +266,6 @@ public final class Settings {
// package protected setters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// void setShowSqlEnabled(boolean b) {
// showSql = b;
// }
//
// void setFormatSqlEnabled(boolean b) {
// formatSql = b;
// }
void setSqlStatementLogger(SQLStatementLogger sqlStatementLogger) {
this.sqlStatementLogger = sqlStatementLogger;
}
void setDefaultSchemaName(String string) {
defaultSchemaName = string;
}

View File

@ -44,7 +44,6 @@ import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.transaction.spi.TransactionFactory;
import org.hibernate.hql.QueryTranslatorFactory;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.jdbc.util.SQLStatementLogger;
import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.service.spi.ServiceRegistry;
import org.hibernate.util.ReflectHelper;
@ -214,15 +213,6 @@ public class SettingsFactory implements Serializable {
//Statistics and logging:
boolean showSql = ConfigurationHelper.getBoolean(Environment.SHOW_SQL, properties);
if (showSql) log.info("Echoing all SQL to stdout");
// settings.setShowSqlEnabled(showSql);
boolean formatSql = ConfigurationHelper.getBoolean(Environment.FORMAT_SQL, properties);
// settings.setFormatSqlEnabled(formatSql);
settings.setSqlStatementLogger( new SQLStatementLogger( showSql, formatSql ) );
boolean useStatistics = ConfigurationHelper.getBoolean(Environment.GENERATE_STATISTICS, properties);
log.info( "Statistics: " + enabledDisabled(useStatistics) );
settings.setStatisticsEnabled(useStatistics);

View File

@ -29,15 +29,13 @@ import java.util.Properties;
import java.util.Set;
import java.sql.Connection;
import javax.transaction.TransactionManager;
import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
import org.hibernate.MappingException;
import org.hibernate.SessionFactory;
import org.hibernate.ConnectionReleaseMode;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.SQLExceptionHelper;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.engine.query.QueryPlanCache;
import org.hibernate.engine.profile.FetchProfile;
@ -202,12 +200,12 @@ public interface SessionFactoryImplementor extends Mapping, SessionFactory {
// TODO: deprecate???
/**
* Retrieves the SQLExceptionHelper in effect for this SessionFactory.
* Retrieves the SqlExceptionHelper in effect for this SessionFactory.
*
* @return The SQLExceptionHelper for this SessionFactory.
* @return The SqlExceptionHelper for this SessionFactory.
*
*/
public SQLExceptionHelper getSQLExceptionHelper();
public SqlExceptionHelper getSQLExceptionHelper();
public Settings getSettings();

View File

@ -27,8 +27,8 @@ import org.hibernate.engine.jdbc.batch.spi.Batch;
import org.hibernate.engine.jdbc.batch.spi.BatchKey;
import org.hibernate.engine.jdbc.batch.spi.BatchObserver;
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
import org.hibernate.engine.jdbc.spi.SQLExceptionHelper;
import org.hibernate.engine.jdbc.spi.SQLStatementLogger;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -74,7 +74,7 @@ public abstract class AbstractBatchImpl implements Batch {
*
* @return The underlying SQLException helper.
*/
protected SQLExceptionHelper sqlExceptionHelper() {
protected SqlExceptionHelper sqlExceptionHelper() {
return jdbcCoordinator.getTransactionCoordinator()
.getTransactionContext()
.getTransactionEnvironment()
@ -87,7 +87,7 @@ public abstract class AbstractBatchImpl implements Batch {
*
* @return The underlying JDBC services.
*/
protected SQLStatementLogger sqlStatementLogger() {
protected SqlStatementLogger sqlStatementLogger() {
return jdbcCoordinator.getTransactionCoordinator()
.getTransactionContext()
.getTransactionEnvironment()

View File

@ -22,7 +22,7 @@
* Boston, MA 02110-1301 USA
*
*/
package org.hibernate.jdbc.util;
package org.hibernate.engine.jdbc.internal;
import java.util.HashSet;
import java.util.LinkedList;
@ -39,12 +39,12 @@ import org.hibernate.util.StringHelper;
*/
public class BasicFormatterImpl implements Formatter {
private static final Set BEGIN_CLAUSES = new HashSet();
private static final Set END_CLAUSES = new HashSet();
private static final Set LOGICAL = new HashSet();
private static final Set QUANTIFIERS = new HashSet();
private static final Set DML = new HashSet();
private static final Set MISC = new HashSet();
private static final Set<String> BEGIN_CLAUSES = new HashSet<String>();
private static final Set<String> END_CLAUSES = new HashSet<String>();
private static final Set<String> LOGICAL = new HashSet<String>();
private static final Set<String> QUANTIFIERS = new HashSet<String>();
private static final Set<String> DML = new HashSet<String>();
private static final Set<String> MISC = new HashSet<String>();
static {
BEGIN_CLAUSES.add( "left" );
@ -101,8 +101,8 @@ public class BasicFormatterImpl implements Formatter {
boolean afterInsert = false;
int inFunction = 0;
int parensSinceSelect = 0;
private LinkedList parenCounts = new LinkedList();
private LinkedList afterByOrFromOrSelects = new LinkedList();
private LinkedList<Integer> parenCounts = new LinkedList<Integer>();
private LinkedList<Boolean> afterByOrFromOrSelects = new LinkedList<Boolean>();
int indent = 1;
@ -273,11 +273,12 @@ public class BasicFormatterImpl implements Formatter {
}
}
@SuppressWarnings( {"UnnecessaryBoxing"})
private void select() {
out();
indent++;
newline();
parenCounts.addLast( new Integer( parensSinceSelect ) );
parenCounts.addLast( Integer.valueOf( parensSinceSelect ) );
afterByOrFromOrSelects.addLast( Boolean.valueOf( afterByOrSetOrFromOrSelect ) );
parensSinceSelect = 0;
afterByOrSetOrFromOrSelect = true;
@ -330,12 +331,13 @@ public class BasicFormatterImpl implements Formatter {
afterValues = true;
}
@SuppressWarnings( {"UnnecessaryUnboxing"})
private void closeParen() {
parensSinceSelect--;
if ( parensSinceSelect < 0 ) {
indent--;
parensSinceSelect = ( ( Integer ) parenCounts.removeLast() ).intValue();
afterByOrSetOrFromOrSelect = ( ( Boolean ) afterByOrFromOrSelects.removeLast() ).booleanValue();
parensSinceSelect = parenCounts.removeLast().intValue();
afterByOrSetOrFromOrSelect = afterByOrFromOrSelects.removeLast().booleanValue();
}
if ( inFunction > 0 ) {
inFunction--;

View File

@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@ -20,9 +20,8 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*
*/
package org.hibernate.jdbc.util;
package org.hibernate.engine.jdbc.internal;
import java.util.StringTokenizer;

View File

@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@ -20,19 +20,18 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*
*/
package org.hibernate.jdbc.util;
package org.hibernate.engine.jdbc.internal;
/**
* Represents the the understood types or styles of formatting.
*
* @author Steve Ebersole
*/
public class FormatStyle {
public static final FormatStyle BASIC = new FormatStyle( "basic", new BasicFormatterImpl() );
public static final FormatStyle DDL = new FormatStyle( "ddl", new DDLFormatterImpl() );
public static final FormatStyle NONE = new FormatStyle( "none", new NoFormatImpl() );
public enum FormatStyle {
BASIC( "basic", new BasicFormatterImpl() ),
DDL( "ddl", new DDLFormatterImpl() ),
NONE( "none", new NoFormatImpl() );
private final String name;
private final Formatter formatter;
@ -50,24 +49,6 @@ public class FormatStyle {
return formatter;
}
public boolean equals(Object o) {
if ( this == o ) {
return true;
}
if ( o == null || getClass() != o.getClass() ) {
return false;
}
FormatStyle that = ( FormatStyle ) o;
return name.equals( that.name );
}
public int hashCode() {
return name.hashCode();
}
private static class NoFormatImpl implements Formatter {
public String format(String source) {
return source;

View File

@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@ -20,9 +20,8 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*
*/
package org.hibernate.jdbc.util;
package org.hibernate.engine.jdbc.internal;
/**
* Formatter contract
@ -30,5 +29,12 @@ package org.hibernate.jdbc.util;
* @author Steve Ebersole
*/
public interface Formatter {
/**
* Format the source SQL string.
*
* @param source The original SQL string
*
* @return The formatted version
*/
public String format(String source);
}

View File

@ -30,7 +30,7 @@ import org.hibernate.engine.jdbc.batch.spi.BatchBuilder;
import org.hibernate.engine.jdbc.batch.spi.BatchKey;
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
import org.hibernate.engine.jdbc.spi.LogicalConnectionImplementor;
import org.hibernate.engine.jdbc.spi.SQLExceptionHelper;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.engine.jdbc.spi.StatementPreparer;
import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl;
import org.hibernate.engine.transaction.spi.TransactionContext;
@ -100,7 +100,7 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator {
return sessionFactory().getServiceRegistry().getService( BatchBuilder.class );
}
private SQLExceptionHelper sqlExceptionHelper() {
private SqlExceptionHelper sqlExceptionHelper() {
return transactionEnvironment().getJdbcServices().getSqlExceptionHelper();
}

View File

@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
import org.hibernate.HibernateException;
import org.hibernate.engine.jdbc.spi.JdbcWrapper;
import org.hibernate.engine.jdbc.spi.SQLExceptionHelper;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.engine.jdbc.spi.JdbcResourceRegistry;
import org.hibernate.engine.jdbc.spi.InvalidatableWrapper;
@ -50,11 +50,11 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry {
private final HashMap<Statement,Set<ResultSet>> xref = new HashMap<Statement,Set<ResultSet>>();
private final Set<ResultSet> unassociatedResultSets = new HashSet<ResultSet>();
private final SQLExceptionHelper exceptionHelper;
private final SqlExceptionHelper exceptionHelper;
private Statement lastQuery;
public JdbcResourceRegistryImpl(SQLExceptionHelper exceptionHelper) {
public JdbcResourceRegistryImpl(SqlExceptionHelper exceptionHelper) {
this.exceptionHelper = exceptionHelper;
}

View File

@ -38,19 +38,17 @@ import org.slf4j.LoggerFactory;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.jdbc.dialect.spi.DialectFactory;
import org.hibernate.engine.jdbc.spi.ExtractedDatabaseMetaData;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.SQLExceptionHelper;
import org.hibernate.engine.jdbc.spi.SQLStatementLogger;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.engine.jdbc.spi.SchemaNameResolver;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.internal.util.jdbc.TypeInfo;
import org.hibernate.service.spi.Configurable;
import org.hibernate.service.spi.InjectService;
import org.hibernate.util.ReflectHelper;
import org.hibernate.internal.util.jdbc.TypeInfoExtracter;
/**
* Standard implementation of the {@link JdbcServices} contract
@ -75,8 +73,8 @@ public class JdbcServicesImpl implements JdbcServices, Configurable {
}
private Dialect dialect;
private SQLStatementLogger sqlStatementLogger;
private SQLExceptionHelper sqlExceptionHelper;
private SqlStatementLogger sqlStatementLogger;
private SqlExceptionHelper sqlExceptionHelper;
private ExtractedDatabaseMetaData extractedMetaDataSupport;
public void configure(Map configValues) {
@ -167,8 +165,8 @@ public class JdbcServicesImpl implements JdbcServices, Configurable {
final boolean formatSQL = ConfigurationHelper.getBoolean( Environment.FORMAT_SQL, configValues, false );
this.dialect = dialect;
this.sqlStatementLogger = new SQLStatementLogger( showSQL, formatSQL );
this.sqlExceptionHelper = new SQLExceptionHelper( dialect.buildSQLExceptionConverter() );
this.sqlStatementLogger = new SqlStatementLogger( showSQL, formatSQL );
this.sqlExceptionHelper = new SqlExceptionHelper( dialect.buildSQLExceptionConverter() );
this.extractedMetaDataSupport = new ExtractedDatabaseMetaDataImpl(
metaSupportsScrollable,
metaSupportsGetGeneratedKeys,
@ -321,11 +319,11 @@ public class JdbcServicesImpl implements JdbcServices, Configurable {
return connectionProvider;
}
public SQLStatementLogger getSqlStatementLogger() {
public SqlStatementLogger getSqlStatementLogger() {
return sqlStatementLogger;
}
public SQLExceptionHelper getSqlExceptionHelper() {
public SqlExceptionHelper getSqlExceptionHelper() {
return sqlExceptionHelper;
}

View File

@ -28,7 +28,7 @@ import org.hibernate.ScrollMode;
import org.hibernate.TransactionException;
import org.hibernate.cfg.Settings;
import org.hibernate.engine.jdbc.spi.LogicalConnectionImplementor;
import org.hibernate.engine.jdbc.spi.SQLExceptionHelper;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.engine.jdbc.spi.StatementPreparer;
import java.sql.Connection;
@ -59,7 +59,7 @@ class StatementPreparerImpl implements StatementPreparer {
return jdbcCoordinator.getLogicalConnection();
}
protected final SQLExceptionHelper sqlExceptionHelper() {
protected final SqlExceptionHelper sqlExceptionHelper() {
return jdbcCoordinator.getTransactionCoordinator()
.getTransactionContext()
.getTransactionEnvironment()

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.internal.util.jdbc;
package org.hibernate.engine.jdbc.internal;
/**
* Models type info extracted from {@link java.sql.DatabaseMetaData#getTypeInfo()}

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.internal.util.jdbc;
package org.hibernate.engine.jdbc.internal;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.internal.util.jdbc;
package org.hibernate.engine.jdbc.internal;
import java.sql.DatabaseMetaData;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.internal.util.jdbc;
package org.hibernate.engine.jdbc.internal;
import java.sql.DatabaseMetaData;

View File

@ -26,7 +26,7 @@ package org.hibernate.engine.jdbc.spi;
import java.util.LinkedHashSet;
import java.util.Set;
import org.hibernate.internal.util.jdbc.TypeInfo;
import org.hibernate.engine.jdbc.internal.TypeInfo;
/**
* Information extracted from {@link java.sql.DatabaseMetaData} regarding what the JDBC driver reports as

View File

@ -55,14 +55,14 @@ public interface JdbcServices extends Service {
*
* @return The SQL statement logger.
*/
public SQLStatementLogger getSqlStatementLogger();
public SqlStatementLogger getSqlStatementLogger();
/**
* Obtain service for dealing with exceptions.
*
* @return The exception helper service.
*/
public SQLExceptionHelper getSqlExceptionHelper();
public SqlExceptionHelper getSqlExceptionHelper();
/**
* Obtain infomration about supported behavior reported by the JDBC driver.

View File

@ -42,8 +42,8 @@ import org.hibernate.util.StringHelper;
*
* @author Steve Ebersole
*/
public class SQLExceptionHelper implements Serializable {
private static final Logger log = LoggerFactory.getLogger( SQLExceptionHelper.class );
public class SqlExceptionHelper implements Serializable {
private static final Logger log = LoggerFactory.getLogger( SqlExceptionHelper.class );
public static final String DEFAULT_EXCEPTION_MSG = "SQL Exception";
public static final String DEFAULT_WARNING_MSG = "SQL Warning";
@ -61,7 +61,7 @@ public class SQLExceptionHelper implements Serializable {
/**
* Create an exception helper with a default exception converter.
*/
public SQLExceptionHelper() {
public SqlExceptionHelper() {
sqlExceptionConverter = DEFAULT_CONVERTER;
}
@ -70,7 +70,7 @@ public class SQLExceptionHelper implements Serializable {
*
* @param sqlExceptionConverter The exception converter to use.
*/
public SQLExceptionHelper(SQLExceptionConverter sqlExceptionConverter) {
public SqlExceptionHelper(SQLExceptionConverter sqlExceptionConverter) {
this.sqlExceptionConverter = sqlExceptionConverter;
}

View File

@ -26,34 +26,34 @@ package org.hibernate.engine.jdbc.spi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.hibernate.jdbc.util.FormatStyle;
import org.hibernate.jdbc.util.Formatter;
import org.hibernate.engine.jdbc.internal.FormatStyle;
import org.hibernate.engine.jdbc.internal.Formatter;
/**
* Centralize logging for SQL statements.
*
* @author Steve Ebersole
*/
public class SQLStatementLogger {
private static final Logger log = LoggerFactory.getLogger( SQLStatementLogger.class );
public class SqlStatementLogger {
private static final Logger log = LoggerFactory.getLogger( SqlStatementLogger.class );
private boolean logToStdout;
private boolean format;
/**
* Constructs a new SQLStatementLogger instance.
* Constructs a new SqlStatementLogger instance.
*/
public SQLStatementLogger() {
public SqlStatementLogger() {
this( false, false );
}
/**
* Constructs a new SQLStatementLogger instance.
* Constructs a new SqlStatementLogger instance.
*
* @param logToStdout Should we log to STDOUT in addition to our internal logger.
* @param format Should we format the statements prior to logging
*/
public SQLStatementLogger(boolean logToStdout, boolean format) {
public SqlStatementLogger(boolean logToStdout, boolean format) {
this.logToStdout = logToStdout;
this.format = format;
}

View File

@ -31,7 +31,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.hibernate.HibernateException;
import org.hibernate.engine.jdbc.spi.SQLExceptionHelper;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.engine.transaction.spi.IsolationDelegate;
import org.hibernate.engine.transaction.spi.TransactionCoordinator;
import org.hibernate.jdbc.ReturningWork;
@ -56,7 +56,7 @@ public class JdbcIsolationDelegate implements IsolationDelegate {
return transactionCoordinator.getJdbcCoordinator().getLogicalConnection().getJdbcServices().getConnectionProvider();
}
protected SQLExceptionHelper sqlExceptionHelper() {
protected SqlExceptionHelper sqlExceptionHelper() {
return transactionCoordinator.getJdbcCoordinator().getLogicalConnection().getJdbcServices().getSqlExceptionHelper();
}

View File

@ -34,7 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.hibernate.HibernateException;
import org.hibernate.engine.jdbc.spi.SQLExceptionHelper;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.engine.transaction.spi.IsolationDelegate;
import org.hibernate.engine.transaction.spi.TransactionCoordinator;
import org.hibernate.jdbc.ReturningWork;
@ -69,7 +69,7 @@ public class JtaIsolationDelegate implements IsolationDelegate {
.getConnectionProvider();
}
protected SQLExceptionHelper sqlExceptionHelper() {
protected SqlExceptionHelper sqlExceptionHelper() {
return transactionCoordinator.getTransactionContext()
.getTransactionEnvironment()
.getJdbcServices()

View File

@ -29,13 +29,13 @@ import org.hibernate.MappingException;
import org.hibernate.cfg.ObjectNameNormalizer;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.jdbc.internal.FormatStyle;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.SQLStatementLogger;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.id.enhanced.AccessCallback;
import org.hibernate.id.enhanced.OptimizerFactory;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.jdbc.ReturningWork;
import org.hibernate.jdbc.util.FormatStyle;
import org.hibernate.mapping.Table;
import org.hibernate.type.Type;
import org.slf4j.Logger;
@ -150,7 +150,7 @@ public class MultipleHiLoPerTableGenerator implements PersistentIdentifierGenera
@Override
public IntegralDataTypeHolder execute(Connection connection) throws SQLException {
IntegralDataTypeHolder value = IdentifierGeneratorHelper.getIntegralDataTypeHolder( returnClass );
SQLStatementLogger statementLogger = session
SqlStatementLogger statementLogger = session
.getFactory()
.getServiceRegistry()
.getService( JdbcServices.class )

View File

@ -28,11 +28,11 @@ import org.hibernate.LockMode;
import org.hibernate.cfg.ObjectNameNormalizer;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.jdbc.internal.FormatStyle;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.SQLStatementLogger;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.jdbc.ReturningWork;
import org.hibernate.jdbc.util.FormatStyle;
import org.hibernate.mapping.Table;
import org.hibernate.type.Type;
import org.slf4j.Logger;
@ -139,7 +139,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
}
protected IntegralDataTypeHolder generateHolder(SessionImplementor session) {
final SQLStatementLogger statementLogger = session
final SqlStatementLogger statementLogger = session
.getFactory()
.getServiceRegistry()
.getService( JdbcServices.class )

View File

@ -32,14 +32,14 @@ import org.hibernate.cfg.ObjectNameNormalizer;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.SQLStatementLogger;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.id.Configurable;
import org.hibernate.id.IdentifierGeneratorHelper;
import org.hibernate.id.IntegralDataTypeHolder;
import org.hibernate.id.PersistentIdentifierGenerator;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.engine.jdbc.internal.FormatStyle;
import org.hibernate.jdbc.ReturningWork;
import org.hibernate.jdbc.util.FormatStyle;
import org.hibernate.mapping.Table;
import org.hibernate.type.Type;
import org.hibernate.util.StringHelper;
@ -455,7 +455,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
@Override
public synchronized Serializable generate(final SessionImplementor session, Object obj) {
final SQLStatementLogger statementLogger = session
final SqlStatementLogger statementLogger = session
.getFactory()
.getServiceRegistry()
.getService( JdbcServices.class )

View File

@ -28,12 +28,12 @@ import org.hibernate.LockMode;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.SQLStatementLogger;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.id.IdentifierGenerationException;
import org.hibernate.id.IdentifierGeneratorHelper;
import org.hibernate.id.IntegralDataTypeHolder;
import org.hibernate.jdbc.ReturningWork;
import org.hibernate.jdbc.util.FormatStyle;
import org.hibernate.engine.jdbc.internal.FormatStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -118,7 +118,7 @@ public class TableStructure implements DatabaseStructure {
new ReturningWork<IntegralDataTypeHolder>() {
@Override
public IntegralDataTypeHolder execute(Connection connection) throws SQLException {
final SQLStatementLogger statementLogger = session
final SqlStatementLogger statementLogger = session
.getFactory()
.getServiceRegistry()
.getService( JdbcServices.class )

View File

@ -63,7 +63,7 @@ import org.hibernate.engine.NamedSQLQueryDefinition;
import org.hibernate.engine.ResultSetMappingDefinition;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.SQLExceptionHelper;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.engine.profile.Association;
import org.hibernate.engine.profile.Fetch;
import org.hibernate.engine.profile.FetchProfile;
@ -80,7 +80,6 @@ import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.RootClass;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metadata.CollectionMetadata;
import org.hibernate.persister.internal.PersisterFactoryImpl;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Loadable;
@ -737,7 +736,7 @@ public final class SessionFactoryImpl
return getSQLExceptionHelper().getSqlExceptionConverter();
}
public SQLExceptionHelper getSQLExceptionHelper() {
public SqlExceptionHelper getSQLExceptionHelper() {
return getJdbcServices().getSqlExceptionHelper();
}

View File

@ -27,12 +27,7 @@
<head></head>
<body>
<p>
This package abstracts the mechanism for dispatching SQL statements
to the database, and implements interaction with JDBC.
</p>
<p>
Concrete implementations of the <tt>Batcher</tt> interface may be
selected by specifying <tt>hibernate.jdbc.factory_class</tt>.
Essentially defines {@link Work}, {@link ReturningWork} and {@link Expectation} as well as some exceptions
</p>
</body>
</html>

View File

@ -1,120 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*
*/
package org.hibernate.jdbc.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Centralize logging handling for SQL statements.
*
* @author Steve Ebersole
*/
public class SQLStatementLogger {
// todo : for 4.0
// private static final Logger log = LoggerFactory.getLogger( SQLStatementLogger.class );
// this is the legacy logging 'category'...
private static final Logger log = LoggerFactory.getLogger( "org.hibernate.SQL" );
private boolean logToStdout;
private boolean formatSql;
/**
* Constructs a new SQLStatementLogger instance.
*/
public SQLStatementLogger() {
this( false, false );
}
/**
* Constructs a new SQLStatementLogger instance.
*
* @param logToStdout Should we log to STDOUT in addition to our internal logger.
* @param formatSql Should we format SQL ('prettify') prior to logging.
*/
public SQLStatementLogger(boolean logToStdout, boolean formatSql) {
this.logToStdout = logToStdout;
this.formatSql = formatSql;
}
/**
* Getter for property 'logToStdout'.
* @see #setLogToStdout
*
* @return Value for property 'logToStdout'.
*/
public boolean isLogToStdout() {
return logToStdout;
}
/**
* Setter for property 'logToStdout'.
*
* @param logToStdout Value to set for property 'logToStdout'.
*/
public void setLogToStdout(boolean logToStdout) {
this.logToStdout = logToStdout;
}
/**
* Getter for property 'formatSql'.
* @see #setFormatSql
*
* @return Value for property 'formatSql'.
*/
public boolean isFormatSql() {
return formatSql;
}
/**
* Setter for property 'formatSql'.
*
* @param formatSql Value to set for property 'formatSql'.
*/
public void setFormatSql(boolean formatSql) {
this.formatSql = formatSql;
}
/**
* Log a SQL statement string.
*
* @param statement The SQL statement.
* @param style The requested formatting style.
*/
public void logStatement(String statement, FormatStyle style) {
if ( log.isDebugEnabled() || logToStdout ) {
style = determineActualStyle( style );
statement = style.getFormatter().format( statement );
}
log.debug( statement );
if ( logToStdout ) {
System.out.println( "Hibernate: " + statement );
}
}
private FormatStyle determineActualStyle(FormatStyle style) {
return formatSql ? style : FormatStyle.NONE;
}
}

View File

@ -26,7 +26,7 @@ package org.hibernate.metamodel.relational;
/**
* Models a JDBC {@link java.sql.Types DATATYPE}
*
* @todo Do we somehow link this in with {@link org.hibernate.internal.util.jdbc.TypeInfo} ?
* @todo Do we somehow link this in with {@link org.hibernate.engine.jdbc.internal.TypeInfo} ?
*
* @author Steve Ebersole
*/

View File

@ -46,7 +46,7 @@ import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.SubselectFetch;
import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey;
import org.hibernate.engine.jdbc.spi.SQLExceptionHelper;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.exception.SQLExceptionConverter;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.jdbc.Expectation;
@ -178,7 +178,7 @@ public abstract class AbstractCollectionPersister
private final String entityName;
private final Dialect dialect;
private final SQLExceptionHelper sqlExceptionHelper;
private final SqlExceptionHelper sqlExceptionHelper;
private final SessionFactoryImplementor factory;
private final EntityPersister ownerPersister;
private final IdentifierGenerator identifierGenerator;
@ -1695,7 +1695,7 @@ public abstract class AbstractCollectionPersister
}
// TODO: needed???
protected SQLExceptionHelper getSQLExceptionHelper() {
protected SqlExceptionHelper getSQLExceptionHelper() {
return sqlExceptionHelper;
}

View File

@ -50,11 +50,11 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.internal.FormatStyle;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.SQLStatementLogger;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.jdbc.util.FormatStyle;
import org.hibernate.jdbc.util.Formatter;
import org.hibernate.engine.jdbc.internal.Formatter;
import org.hibernate.util.ConfigHelper;
import org.hibernate.util.JDBCExceptionReporter;
import org.hibernate.util.ReflectHelper;
@ -79,7 +79,7 @@ public class SchemaExport {
private final List exceptions = new ArrayList();
private boolean haltOnError = false;
private Formatter formatter;
private SQLStatementLogger sqlStatementLogger;
private SqlStatementLogger sqlStatementLogger;
private static final String DEFAULT_IMPORT_FILE = "/import.sql";
/**

View File

@ -39,12 +39,11 @@ import org.hibernate.JDBCException;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.cfg.Settings;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.internal.FormatStyle;
import org.hibernate.engine.jdbc.internal.Formatter;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.jdbc.util.FormatStyle;
import org.hibernate.jdbc.util.Formatter;
import org.hibernate.engine.jdbc.spi.SQLStatementLogger;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.util.ReflectHelper;
import org.slf4j.Logger;
@ -68,7 +67,7 @@ public class SchemaUpdate {
private String outputFile = null;
private String delimiter;
private Formatter formatter;
private SQLStatementLogger sqlStatementLogger;
private SqlStatementLogger sqlStatementLogger;
public SchemaUpdate(Configuration cfg) throws HibernateException {
this( cfg, cfg.getProperties() );

View File

@ -19,6 +19,8 @@ import java.util.StringTokenizer;
import junit.framework.TestCase;
import org.hibernate.engine.jdbc.internal.FormatStyle;
/**
* BasicFormatterTest implementation
*

View File

@ -29,11 +29,11 @@ import java.util.Set;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.JdbcSupport;
import org.hibernate.engine.jdbc.internal.TypeInfo;
import org.hibernate.engine.jdbc.spi.ExtractedDatabaseMetaData;
import org.hibernate.engine.jdbc.spi.SQLExceptionHelper;
import org.hibernate.engine.jdbc.spi.SQLStatementLogger;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.internal.util.jdbc.TypeInfo;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.Stoppable;
@ -47,8 +47,8 @@ import org.hibernate.service.spi.Stoppable;
public class BasicTestingJdbcServiceImpl implements JdbcServices {
private ConnectionProvider connectionProvider;
private Dialect dialect;
private SQLStatementLogger sqlStatementLogger;
private SQLExceptionHelper exceptionHelper;
private SqlStatementLogger sqlStatementLogger;
private SqlExceptionHelper exceptionHelper;
private final ExtractedDatabaseMetaData metaDataSupport = new MetaDataSupportImpl();
@ -62,8 +62,8 @@ public class BasicTestingJdbcServiceImpl implements JdbcServices {
public void prepare(boolean allowAggressiveRelease) {
connectionProvider = ConnectionProviderBuilder.buildConnectionProvider( allowAggressiveRelease );
dialect = ConnectionProviderBuilder.getCorrespondingDialect();
sqlStatementLogger = new SQLStatementLogger( true, false );
exceptionHelper = new SQLExceptionHelper();
sqlStatementLogger = new SqlStatementLogger( true, false );
exceptionHelper = new SqlExceptionHelper();
}
@ -85,11 +85,11 @@ public class BasicTestingJdbcServiceImpl implements JdbcServices {
return null;
}
public SQLStatementLogger getSqlStatementLogger() {
public SqlStatementLogger getSqlStatementLogger() {
return sqlStatementLogger;
}
public SQLExceptionHelper getSqlExceptionHelper() {
public SqlExceptionHelper getSqlExceptionHelper() {
return exceptionHelper;
}

View File

@ -27,8 +27,8 @@ import java.sql.Connection;
import java.sql.SQLException;
import java.util.LinkedHashSet;
import org.hibernate.internal.util.jdbc.TypeInfo;
import org.hibernate.internal.util.jdbc.TypeInfoExtracter;
import org.hibernate.engine.jdbc.internal.TypeInfo;
import org.hibernate.engine.jdbc.internal.TypeInfoExtracter;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.test.common.ConnectionProviderBuilder;
import org.hibernate.testing.junit.UnitTestCase;