Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,40 +140,48 @@ public interface JdbcLogging extends BasicLogger {
id = 100018)
void logDriverInfo(String name, String version, int major, int minor, int jdbcMajor, int jdbcMinor);

@LogMessage(level = TRACE)
@Message(value = "Unable to reset connection back to auto-commit", id = 100019)
void unableToResetAutoCommit(@Cause Exception ignored);

@LogMessage(level = INFO)
@Message(value = "Unable to release isolated connection", id = 100020)
void unableToReleaseIsolatedConnection(@Cause Exception ignored);

@LogMessage(level = DEBUG)
@Message(value = "Unable to release connection", id = 100021)
void unableToReleaseConnection(@Cause Exception ignored);

@LogMessage(level = INFO)
@Message(value = "Unable to roll back isolated connection on exception ", id = 100021)
@Message(value = "Unable to roll back isolated connection on exception ", id = 100022)
void unableToRollBackIsolatedConnection(@Cause Exception ignored);

@LogMessage(level = TRACE)
@Message(value = "Unable to reset connection back to auto-commit enabled", id = 100040)
void unableToResetAutoCommitEnabled(@Cause Exception ignored);

@LogMessage(level = TRACE)
@Message(value = "Unable to reset connection back to auto-commit disabled", id = 100041)
void unableToResetAutoCommitDisabled(@Cause Exception ignored);

@LogMessage(level = DEBUG)
@Message(value = "Using default JDBC fetch size: %s", id = 100022)
@Message(value = "Using default JDBC fetch size: %s", id = 100122)
void usingFetchSize(int fetchSize);

@LogMessage(level = WARN)
@Message(value = "Low default JDBC fetch size: %s (consider setting 'hibernate.jdbc.fetch_size')", id = 100023)
@Message(value = "Low default JDBC fetch size: %s (consider setting 'hibernate.jdbc.fetch_size')", id = 100123)
void warnLowFetchSize(int fetchSize);

@LogMessage(level = TRACE)
@Message(value = "JDBC fetch size: %s", id = 100024)
@Message(value = "JDBC fetch size: %s", id = 100124)
void fetchSize(int fetchSize);

@LogMessage(level = DEBUG)
@Message(value = "Low JDBC fetch size: %s (consider setting 'hibernate.jdbc.fetch_size')", id = 100025)
@Message(value = "Low JDBC fetch size: %s (consider setting 'hibernate.jdbc.fetch_size')", id = 100125)
void lowFetchSize(int fetchSize);

@LogMessage(level = TRACE)
@Message(value = "Setting JDBC fetch size: %s", id = 100026)
@Message(value = "Setting JDBC fetch size: %s", id = 100126)
void settingFetchSize(int fetchSize);

@LogMessage(level = TRACE)
@Message(value = "Setting JDBC query timeout: %s", id = 100027)
@Message(value = "Setting JDBC query timeout: %s", id = 100127)
void settingQueryTimeout(int timeout);

@LogMessage(level = WARN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import org.hibernate.HibernateException;
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
Expand All @@ -22,7 +20,9 @@
import org.hibernate.tool.schema.extract.spi.ExtractionContext;
import org.hibernate.tool.schema.extract.spi.SequenceInformation;

import static java.util.Collections.emptyList;
import static java.util.stream.StreamSupport.stream;
import static org.hibernate.engine.jdbc.JdbcLogging.JDBC_MESSAGE_LOGGER;

/**
* Standard implementation of {@link ExtractedDatabaseMetaData}
Expand Down Expand Up @@ -189,7 +189,7 @@ public synchronized List<SequenceInformation> getSequenceInformationList() {
return sequenceInformationList;
}
else {
return Collections.emptyList();
return emptyList();
}
}

Expand Down Expand Up @@ -335,7 +335,7 @@ private List<SequenceInformation> sequenceInformationList() {
try {
connection = connectionAccess.obtainConnection();
return stream( sequenceInformation( connection, jdbcEnvironment ).spliterator(), false )
.collect( Collectors.toList() );
.toList();
}
catch (SQLException e) {
throw new HibernateException( "Could not fetch the SequenceInformation from the database", e );
Expand All @@ -346,7 +346,7 @@ private List<SequenceInformation> sequenceInformationList() {
connectionAccess.releaseConnection( connection );
}
catch (SQLException exception) {
//ignored
JDBC_MESSAGE_LOGGER.unableToReleaseConnection( exception );
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.hibernate.query.sqm.mutation.spi.AfterUseAction;
import org.jboss.logging.Logger;

import static org.hibernate.engine.jdbc.JdbcLogging.JDBC_MESSAGE_LOGGER;

/**
* Strategy based on ANSI SQL's definition of a "global temporary table".
*
Expand Down Expand Up @@ -91,7 +93,8 @@ public void prepare(MappingModelCreationProcess mappingModelCreationProcess, Jdb
try {
connectionAccess.releaseConnection( connection );
}
catch (SQLException ignore) {
catch (SQLException exception) {
JDBC_MESSAGE_LOGGER.unableToReleaseConnection( exception );
}
}
}
Expand Down Expand Up @@ -132,7 +135,8 @@ public void release(SessionFactoryImplementor sessionFactory, JdbcConnectionAcce
try {
connectionAccess.releaseConnection( connection );
}
catch (SQLException ignore) {
catch (SQLException exception) {
JDBC_MESSAGE_LOGGER.unableToReleaseConnection( exception );
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.hibernate.query.sqm.mutation.spi.AfterUseAction;
import org.jboss.logging.Logger;

import static org.hibernate.engine.jdbc.JdbcLogging.JDBC_MESSAGE_LOGGER;

/**
* This is a strategy that mimics temporary tables for databases which do not support
* temporary tables. It follows a pattern similar to the ANSI SQL definition of global
Expand Down Expand Up @@ -116,7 +118,8 @@ public void prepare(
try {
connectionAccess.releaseConnection( connection );
}
catch (SQLException ignore) {
catch (SQLException exception) {
JDBC_MESSAGE_LOGGER.unableToReleaseConnection( exception );
}
}
}
Expand Down Expand Up @@ -156,7 +159,8 @@ public void release(
try {
connectionAccess.releaseConnection( connection );
}
catch (SQLException ignore) {
catch (SQLException exception) {
JDBC_MESSAGE_LOGGER.unableToReleaseConnection( exception );
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private static void resetAutoCommit(boolean transacted, boolean wasAutoCommit, C
connection.setAutoCommit( true );
}
catch ( Exception exception ) {
JDBC_MESSAGE_LOGGER.unableToResetAutoCommit( exception );
JDBC_MESSAGE_LOGGER.unableToResetAutoCommitEnabled( exception );
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.hibernate.service.ServiceRegistry;
import org.hibernate.tool.schema.extract.spi.ExtractionContext;

import static org.hibernate.engine.jdbc.JdbcLogging.JDBC_MESSAGE_LOGGER;

/**
* @author Steve Ebersole
*/
Expand Down Expand Up @@ -109,7 +111,8 @@ public void cleanup() {
try {
jdbcConnectionAccess.releaseConnection( jdbcConnection );
}
catch (SQLException ignore) {
catch (SQLException exception) {
JDBC_MESSAGE_LOGGER.unableToReleaseConnection( exception );
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public void release() {
// and we don't have access to it upon releasing via the DdlTransactionIsolatorProvidedConnectionImpl.
connectionAccess.releaseConnection( null );
}
catch (SQLException ignored) {
JDBC_MESSAGE_LOGGER.unableToReleaseIsolatedConnection( ignored );
catch (SQLException exception) {
JDBC_MESSAGE_LOGGER.unableToReleaseIsolatedConnection( exception );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

import org.jboss.logging.Logger;

import static org.hibernate.engine.jdbc.JdbcLogging.JDBC_MESSAGE_LOGGER;

/**
* Implementation of JdbcConnectionAccess for use in cases where we
* leverage a ConnectionProvider for access to JDBC Connections.
Expand Down Expand Up @@ -43,14 +45,14 @@ public JdbcConnectionAccessConnectionProviderImpl(ConnectionProvider connectionP
try {
jdbcConnection.setAutoCommit( true );
}
catch (SQLException e) {
catch (SQLException exception) {
throw new PersistenceException(
String.format(
"Could not set provided connection [%s] to auto-commit mode" +
" (needed for schema generation)",
jdbcConnection
),
e
exception
);
}
}
Expand Down Expand Up @@ -88,8 +90,8 @@ public void releaseConnection(Connection connection) throws SQLException {
jdbcConnection.setAutoCommit( false );
}
}
catch (SQLException e) {
log.info( "Was unable to reset JDBC connection to no longer be in auto-commit mode" );
catch (SQLException exception) {
JDBC_MESSAGE_LOGGER.unableToResetAutoCommitDisabled( exception );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

import org.jboss.logging.Logger;

import static org.hibernate.engine.jdbc.JdbcLogging.JDBC_MESSAGE_LOGGER;

/**
* Implementation of JdbcConnectionAccess for cases where we are provided
* a JDBC Connection to use.
Expand All @@ -34,14 +36,14 @@ public JdbcConnectionAccessProvidedConnectionImpl(Connection jdbcConnection) {
try {
jdbcConnection.setAutoCommit( true );
}
catch (SQLException e) {
catch (SQLException exception) {
throw new PersistenceException(
String.format(
"Could not set provided connection [%s] to auto-commit mode" +
" (needed for schema generation)",
jdbcConnection
),
e
exception
);
}
}
Expand All @@ -61,16 +63,17 @@ public Connection obtainConnection() throws SQLException {

@Override
public void releaseConnection(Connection connection) throws SQLException {
// NOTE : reset auto-commit, but *do not* close the Connection. The application handed us this connection
// NOTE: reset auto-commit, but *do not* close the Connection.
// The application handed us this connection.

if ( !wasInitiallyAutoCommit ) {
try {
if ( jdbcConnection.getAutoCommit() ) {
jdbcConnection.setAutoCommit( false );
}
}
catch (SQLException e) {
log.info( "Was unable to reset JDBC connection to no longer be in auto-commit mode" );
catch (SQLException exception) {
JDBC_MESSAGE_LOGGER.unableToResetAutoCommitDisabled( exception );
}
}
}
Expand Down