clean up some warnings in engine.jdbc package
This commit is contained in:
parent
6b51952137
commit
6b5c11b1ff
|
@ -22,7 +22,7 @@ public abstract class AbstractLobCreator implements LobCreator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Clob wrap(Clob clob) {
|
public Clob wrap(Clob clob) {
|
||||||
if ( NClob.class.isInstance( clob ) ) {
|
if ( clob instanceof NClob ) {
|
||||||
return wrap( (NClob) clob );
|
return wrap( (NClob) clob );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.hibernate.type.descriptor.java.DataHelper;
|
||||||
* @author Gail Badner
|
* @author Gail Badner
|
||||||
*/
|
*/
|
||||||
public class ClobProxy implements InvocationHandler {
|
public class ClobProxy implements InvocationHandler {
|
||||||
private static final Class[] PROXY_INTERFACES = new Class[] { Clob.class, ClobImplementer.class };
|
private static final Class<?>[] PROXY_INTERFACES = new Class[] { Clob.class, ClobImplementer.class };
|
||||||
|
|
||||||
private final CharacterStream characterStream;
|
private final CharacterStream characterStream;
|
||||||
private boolean needsReset;
|
private boolean needsReset;
|
||||||
|
|
|
@ -122,30 +122,15 @@ public class ContextualLobCreator extends AbstractLobCreator implements LobCreat
|
||||||
/**
|
/**
|
||||||
* Callback for performing contextual BLOB creation
|
* Callback for performing contextual BLOB creation
|
||||||
*/
|
*/
|
||||||
public static final LobCreationContext.Callback<Blob> CREATE_BLOB_CALLBACK = new LobCreationContext.Callback<Blob>() {
|
public static final LobCreationContext.Callback<Blob> CREATE_BLOB_CALLBACK = Connection::createBlob;
|
||||||
@Override
|
|
||||||
public Blob executeOnConnection(Connection connection) throws SQLException {
|
|
||||||
return connection.createBlob();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback for performing contextual CLOB creation
|
* Callback for performing contextual CLOB creation
|
||||||
*/
|
*/
|
||||||
public static final LobCreationContext.Callback<Clob> CREATE_CLOB_CALLBACK = new LobCreationContext.Callback<Clob>() {
|
public static final LobCreationContext.Callback<Clob> CREATE_CLOB_CALLBACK = Connection::createClob;
|
||||||
@Override
|
|
||||||
public Clob executeOnConnection(Connection connection) throws SQLException {
|
|
||||||
return connection.createClob();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback for performing contextual NCLOB creation
|
* Callback for performing contextual NCLOB creation
|
||||||
*/
|
*/
|
||||||
public static final LobCreationContext.Callback<NClob> CREATE_NCLOB_CALLBACK = new LobCreationContext.Callback<NClob>() {
|
public static final LobCreationContext.Callback<NClob> CREATE_NCLOB_CALLBACK = Connection::createNClob;
|
||||||
@Override
|
|
||||||
public NClob executeOnConnection(Connection connection) throws SQLException {
|
|
||||||
return connection.createNClob();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class NClobProxy extends ClobProxy {
|
||||||
/**
|
/**
|
||||||
* The interfaces used to generate the proxy
|
* The interfaces used to generate the proxy
|
||||||
*/
|
*/
|
||||||
public static final Class[] PROXY_INTERFACES = new Class[] { NClob.class, NClobImplementer.class };
|
public static final Class<?>[] PROXY_INTERFACES = new Class[] { NClob.class, NClobImplementer.class };
|
||||||
|
|
||||||
protected NClobProxy(String string) {
|
protected NClobProxy(String string) {
|
||||||
super( string );
|
super( string );
|
||||||
|
|
|
@ -16,7 +16,7 @@ import java.io.Reader;
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class ReaderInputStream extends InputStream {
|
public class ReaderInputStream extends InputStream {
|
||||||
private Reader reader;
|
private final Reader reader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a ReaderInputStream from a Reader
|
* Constructs a ReaderInputStream from a Reader
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.hibernate.HibernateException;
|
||||||
* @author Gail Badner
|
* @author Gail Badner
|
||||||
*/
|
*/
|
||||||
public class SerializableBlobProxy implements InvocationHandler, Serializable {
|
public class SerializableBlobProxy implements InvocationHandler, Serializable {
|
||||||
private static final Class[] PROXY_INTERFACES = new Class[] { Blob.class, WrappedBlob.class, Serializable.class };
|
private static final Class<?>[] PROXY_INTERFACES = new Class[] { Blob.class, WrappedBlob.class, Serializable.class };
|
||||||
|
|
||||||
private final transient Blob blob;
|
private final transient Blob blob;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.hibernate.HibernateException;
|
||||||
* @author Gail Badner
|
* @author Gail Badner
|
||||||
*/
|
*/
|
||||||
public class SerializableClobProxy implements InvocationHandler, Serializable {
|
public class SerializableClobProxy implements InvocationHandler, Serializable {
|
||||||
private static final Class[] PROXY_INTERFACES = new Class[] { Clob.class, WrappedClob.class, Serializable.class };
|
private static final Class<?>[] PROXY_INTERFACES = new Class[] { Clob.class, WrappedClob.class, Serializable.class };
|
||||||
|
|
||||||
private final transient Clob clob;
|
private final transient Clob clob;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ import java.sql.NClob;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class SerializableNClobProxy extends SerializableClobProxy {
|
public class SerializableNClobProxy extends SerializableClobProxy {
|
||||||
private static final Class[] PROXY_INTERFACES = new Class[] { NClob.class, WrappedNClob.class };
|
private static final Class<?>[] PROXY_INTERFACES = new Class[] { NClob.class, WrappedNClob.class };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a serializable {@link Clob} wrapper around the given {@link Clob}.
|
* Builds a serializable {@link Clob} wrapper around the given {@link Clob}.
|
||||||
|
|
|
@ -20,15 +20,15 @@ import java.io.Serializable;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class Size implements Serializable {
|
public class Size implements Serializable {
|
||||||
public static enum LobMultiplier {
|
public enum LobMultiplier {
|
||||||
NONE( 1 ),
|
NONE( 1 ),
|
||||||
K( NONE.factor * 1024 ),
|
K( NONE.factor * 1024 ),
|
||||||
M( K.factor * 1024 ),
|
M( K.factor * 1024 ),
|
||||||
G( M.factor * 1024 );
|
G( M.factor * 1024 );
|
||||||
|
|
||||||
private long factor;
|
private final long factor;
|
||||||
|
|
||||||
private LobMultiplier(long factor) {
|
LobMultiplier(long factor) {
|
||||||
this.factor = factor;
|
this.factor = factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,100 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
|
||||||
*/
|
|
||||||
package org.hibernate.engine.jdbc;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.io.Writer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stream copying utilities
|
|
||||||
*
|
|
||||||
* @author Steve Ebersole
|
|
||||||
*/
|
|
||||||
public class StreamUtils {
|
|
||||||
/**
|
|
||||||
* Default size to use for reading buffers.
|
|
||||||
*/
|
|
||||||
public static final int DEFAULT_CHUNK_SIZE = 1024;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy the inputStream to the outputStream. Uses a buffer of the default size ({@link #DEFAULT_CHUNK_SIZE}).
|
|
||||||
*
|
|
||||||
* @param inputStream The input stream to read
|
|
||||||
* @param outputStream The output stream to write to
|
|
||||||
*
|
|
||||||
* @return The number of bytes read
|
|
||||||
*
|
|
||||||
* @throws IOException If a problem occurred accessing either stream
|
|
||||||
*/
|
|
||||||
public static long copy(InputStream inputStream, OutputStream outputStream) throws IOException {
|
|
||||||
return copy( inputStream, outputStream, DEFAULT_CHUNK_SIZE );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy the inputStream to the outputStream using a buffer of the specified size
|
|
||||||
*
|
|
||||||
* @param inputStream The input stream to read
|
|
||||||
* @param outputStream The output stream to write to
|
|
||||||
* @param bufferSize The size of the buffer to use for reading
|
|
||||||
*
|
|
||||||
* @return The number of bytes read
|
|
||||||
*
|
|
||||||
* @throws IOException If a problem occurred accessing either stream
|
|
||||||
*/
|
|
||||||
public static long copy(InputStream inputStream, OutputStream outputStream, int bufferSize) throws IOException {
|
|
||||||
final byte[] buffer = new byte[bufferSize];
|
|
||||||
long count = 0;
|
|
||||||
int n;
|
|
||||||
while ( -1 != ( n = inputStream.read( buffer ) ) ) {
|
|
||||||
outputStream.write( buffer, 0, n );
|
|
||||||
count += n;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy the reader to the writer. Uses a buffer of the default size ({@link #DEFAULT_CHUNK_SIZE}).
|
|
||||||
*
|
|
||||||
* @param reader The reader to read from
|
|
||||||
* @param writer The writer to write to
|
|
||||||
*
|
|
||||||
* @return The number of bytes read
|
|
||||||
*
|
|
||||||
* @throws IOException If a problem occurred accessing reader or writer
|
|
||||||
*/
|
|
||||||
public static long copy(Reader reader, Writer writer) throws IOException {
|
|
||||||
return copy( reader, writer, DEFAULT_CHUNK_SIZE );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy the reader to the writer using a buffer of the specified size
|
|
||||||
*
|
|
||||||
* @param reader The reader to read from
|
|
||||||
* @param writer The writer to write to
|
|
||||||
* @param bufferSize The size of the buffer to use for reading
|
|
||||||
*
|
|
||||||
* @return The number of bytes read
|
|
||||||
*
|
|
||||||
* @throws IOException If a problem occurred accessing either stream
|
|
||||||
*/
|
|
||||||
public static long copy(Reader reader, Writer writer, int bufferSize) throws IOException {
|
|
||||||
final char[] buffer = new char[bufferSize];
|
|
||||||
long count = 0;
|
|
||||||
int n;
|
|
||||||
while ( -1 != ( n = reader.read( buffer ) ) ) {
|
|
||||||
writer.write( buffer, 0, n );
|
|
||||||
count += n;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
private StreamUtils() {
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -41,8 +41,8 @@ public abstract class AbstractBatchImpl implements Batch {
|
||||||
private final SqlStatementLogger sqlStatementLogger;
|
private final SqlStatementLogger sqlStatementLogger;
|
||||||
private final SqlExceptionHelper sqlExceptionHelper;
|
private final SqlExceptionHelper sqlExceptionHelper;
|
||||||
|
|
||||||
private LinkedHashMap<String, PreparedStatement> statements = new LinkedHashMap<>();
|
private final LinkedHashMap<String, PreparedStatement> statements = new LinkedHashMap<>();
|
||||||
private LinkedHashSet<BatchObserver> observers = new LinkedHashSet<>();
|
private final LinkedHashSet<BatchObserver> observers = new LinkedHashSet<>();
|
||||||
|
|
||||||
protected AbstractBatchImpl(BatchKey key, JdbcCoordinator jdbcCoordinator) {
|
protected AbstractBatchImpl(BatchKey key, JdbcCoordinator jdbcCoordinator) {
|
||||||
if ( key == null ) {
|
if ( key == null ) {
|
||||||
|
|
|
@ -10,16 +10,13 @@ import org.hibernate.engine.jdbc.batch.spi.Batch;
|
||||||
import org.hibernate.engine.jdbc.batch.spi.BatchBuilder;
|
import org.hibernate.engine.jdbc.batch.spi.BatchBuilder;
|
||||||
import org.hibernate.engine.jdbc.batch.spi.BatchKey;
|
import org.hibernate.engine.jdbc.batch.spi.BatchKey;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
||||||
import org.hibernate.internal.CoreLogging;
|
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A builder for {@link Batch} instances.
|
* A builder for {@link Batch} instances.
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class BatchBuilderImpl implements BatchBuilder, BatchBuilderMXBean {
|
public class BatchBuilderImpl implements BatchBuilder {
|
||||||
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( BatchBuilderImpl.class );
|
|
||||||
|
|
||||||
private volatile int jdbcBatchSize;
|
private volatile int jdbcBatchSize;
|
||||||
|
|
||||||
|
@ -38,12 +35,10 @@ public class BatchBuilderImpl implements BatchBuilder, BatchBuilderMXBean {
|
||||||
this.jdbcBatchSize = jdbcBatchSize;
|
this.jdbcBatchSize = jdbcBatchSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getJdbcBatchSize() {
|
public int getJdbcBatchSize() {
|
||||||
return jdbcBatchSize;
|
return jdbcBatchSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setJdbcBatchSize(int jdbcBatchSize) {
|
public void setJdbcBatchSize(int jdbcBatchSize) {
|
||||||
this.jdbcBatchSize = jdbcBatchSize;
|
this.jdbcBatchSize = jdbcBatchSize;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
|
||||||
*/
|
|
||||||
package org.hibernate.engine.jdbc.batch.internal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The BatchBuilderImpl JMX management interface
|
|
||||||
*
|
|
||||||
* @author Steve Ebersole
|
|
||||||
*/
|
|
||||||
public interface BatchBuilderMXBean {
|
|
||||||
int getJdbcBatchSize();
|
|
||||||
void setJdbcBatchSize(int size);
|
|
||||||
}
|
|
|
@ -93,7 +93,7 @@ public abstract class BasicConnectionCreator implements ConnectionCreator {
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ValueHolder<SQLExceptionConversionDelegate> simpleConverterAccess =
|
private final ValueHolder<SQLExceptionConversionDelegate> simpleConverterAccess =
|
||||||
new ValueHolder<>( () -> new SQLExceptionConversionDelegate() {
|
new ValueHolder<>( () -> new SQLExceptionConversionDelegate() {
|
||||||
private final SQLStateConversionDelegate sqlStateDelegate = new SQLStateConversionDelegate(
|
private final SQLStateConversionDelegate sqlStateDelegate = new SQLStateConversionDelegate(
|
||||||
() -> {
|
() -> {
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class DataSourceBasedMultiTenantConnectionProviderImpl
|
||||||
final Object dataSourceConfigValue = serviceRegistry.getService( ConfigurationService.class )
|
final Object dataSourceConfigValue = serviceRegistry.getService( ConfigurationService.class )
|
||||||
.getSettings()
|
.getSettings()
|
||||||
.get( AvailableSettings.DATASOURCE );
|
.get( AvailableSettings.DATASOURCE );
|
||||||
if ( !String.class.isInstance( dataSourceConfigValue ) ) {
|
if ( !(dataSourceConfigValue instanceof String) ) {
|
||||||
throw new HibernateException( "Improper set up of DataSourceBasedMultiTenantConnectionProviderImpl" );
|
throw new HibernateException( "Improper set up of DataSourceBasedMultiTenantConnectionProviderImpl" );
|
||||||
}
|
}
|
||||||
final String jndiName = (String) dataSourceConfigValue;
|
final String jndiName = (String) dataSourceConfigValue;
|
||||||
|
@ -91,13 +91,13 @@ public class DataSourceBasedMultiTenantConnectionProviderImpl
|
||||||
throw new HibernateException( "JNDI name [" + jndiName + "] could not be resolved" );
|
throw new HibernateException( "JNDI name [" + jndiName + "] could not be resolved" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( DataSource.class.isInstance( namedObject ) ) {
|
if ( namedObject instanceof DataSource ) {
|
||||||
final int loc = jndiName.lastIndexOf( '/' );
|
final int loc = jndiName.lastIndexOf( '/' );
|
||||||
this.baseJndiNamespace = jndiName.substring( 0, loc );
|
this.baseJndiNamespace = jndiName.substring( 0, loc );
|
||||||
this.tenantIdentifierForAny = jndiName.substring( loc + 1 );
|
this.tenantIdentifierForAny = jndiName.substring( loc + 1 );
|
||||||
dataSourceMap().put( tenantIdentifierForAny, (DataSource) namedObject );
|
dataSourceMap().put( tenantIdentifierForAny, (DataSource) namedObject );
|
||||||
}
|
}
|
||||||
else if ( Context.class.isInstance( namedObject ) ) {
|
else if ( namedObject instanceof Context ) {
|
||||||
this.baseJndiNamespace = jndiName;
|
this.baseJndiNamespace = jndiName;
|
||||||
this.tenantIdentifierForAny = (String) serviceRegistry.getService( ConfigurationService.class )
|
this.tenantIdentifierForAny = (String) serviceRegistry.getService( ConfigurationService.class )
|
||||||
.getSettings()
|
.getSettings()
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.engine.jdbc.cursor.internal;
|
package org.hibernate.engine.jdbc.cursor.internal;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.sql.CallableStatement;
|
import java.sql.CallableStatement;
|
||||||
import java.sql.DatabaseMetaData;
|
import java.sql.DatabaseMetaData;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class DefaultSchemaNameResolver implements SchemaNameResolver {
|
||||||
try {
|
try {
|
||||||
final Class<? extends Connection> jdbcConnectionClass = connection.getClass();
|
final Class<? extends Connection> jdbcConnectionClass = connection.getClass();
|
||||||
final Method getSchemaMethod = jdbcConnectionClass.getMethod( "getSchema" );
|
final Method getSchemaMethod = jdbcConnectionClass.getMethod( "getSchema" );
|
||||||
if ( getSchemaMethod != null && getSchemaMethod.getReturnType().equals( String.class ) ) {
|
if ( getSchemaMethod.getReturnType().equals( String.class ) ) {
|
||||||
try {
|
try {
|
||||||
// If the JDBC driver does not implement the Java 7 spec, but the JRE is Java 7
|
// If the JDBC driver does not implement the Java 7 spec, but the JRE is Java 7
|
||||||
// then the getSchemaMethod is not null but the call to getSchema() throws an java.lang.AbstractMethodError
|
// then the getSchemaMethod is not null but the call to getSchema() throws an java.lang.AbstractMethodError
|
||||||
|
@ -59,10 +59,10 @@ public class DefaultSchemaNameResolver implements SchemaNameResolver {
|
||||||
return SchemaNameResolverFallbackDelegate.INSTANCE;
|
return SchemaNameResolverFallbackDelegate.INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ignore) {
|
catch (Exception e) {
|
||||||
log.debugf(
|
log.debugf(
|
||||||
"Unable to use Java 1.7 Connection#getSchema : An error occurred trying to resolve the connection default schema resolver: %s",
|
"Unable to use Java 1.7 Connection#getSchema : An error occurred trying to resolve the connection default schema resolver: %s",
|
||||||
ignore.getMessage() );
|
e.getMessage() );
|
||||||
return SchemaNameResolverFallbackDelegate.INSTANCE;
|
return SchemaNameResolverFallbackDelegate.INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,9 +155,6 @@ public class JdbcEnvironmentImpl implements JdbcEnvironment {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor form used from testing
|
* Constructor form used from testing
|
||||||
*
|
|
||||||
* @param dialect The dialect
|
|
||||||
* @param jdbcConnectionAccess
|
|
||||||
*/
|
*/
|
||||||
public JdbcEnvironmentImpl(
|
public JdbcEnvironmentImpl(
|
||||||
DatabaseMetaData databaseMetaData,
|
DatabaseMetaData databaseMetaData,
|
||||||
|
@ -337,13 +334,13 @@ public class JdbcEnvironmentImpl implements JdbcEnvironment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private SqlExceptionHelper buildSqlExceptionHelper(Dialect dialect, boolean logWarnings) {
|
private SqlExceptionHelper buildSqlExceptionHelper(Dialect dialect, boolean logWarnings) {
|
||||||
final StandardSQLExceptionConverter sqlExceptionConverter = new StandardSQLExceptionConverter();
|
final StandardSQLExceptionConverter sqlExceptionConverter = new StandardSQLExceptionConverter(
|
||||||
sqlExceptionConverter.addDelegate( dialect.buildSQLExceptionConversionDelegate() );
|
dialect.buildSQLExceptionConversionDelegate(),
|
||||||
sqlExceptionConverter.addDelegate( new SQLExceptionTypeDelegate( dialect ) );
|
new SQLExceptionTypeDelegate( dialect ),
|
||||||
// todo : vary this based on extractedMetaDataSupport.getSqlStateType()
|
// todo : vary this based on extractedMetaDataSupport.getSqlStateType()
|
||||||
sqlExceptionConverter.addDelegate( new SQLStateConversionDelegate( dialect ) );
|
new SQLStateConversionDelegate( dialect )
|
||||||
|
);
|
||||||
return new SqlExceptionHelper( sqlExceptionConverter, logWarnings );
|
return new SqlExceptionHelper( sqlExceptionConverter, logWarnings );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class LobCreatorBuilderImpl implements LobCreatorBuilder {
|
||||||
* @param jdbcConnection A JDBC {@link Connection} which can be used to gauge the drivers level of support,
|
* @param jdbcConnection A JDBC {@link Connection} which can be used to gauge the drivers level of support,
|
||||||
* specifically for creating LOB references.
|
* specifically for creating LOB references.
|
||||||
*/
|
*/
|
||||||
public static LobCreatorBuilderImpl makeLobCreatorBuilder(Dialect dialect, Map configValues, Connection jdbcConnection) {
|
public static LobCreatorBuilderImpl makeLobCreatorBuilder(Dialect dialect, Map<String,Object> configValues, Connection jdbcConnection) {
|
||||||
return new LobCreatorBuilderImpl( useContextualLobCreation( dialect, configValues, jdbcConnection ) );
|
return new LobCreatorBuilderImpl( useContextualLobCreation( dialect, configValues, jdbcConnection ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public class LobCreatorBuilderImpl implements LobCreatorBuilder {
|
||||||
return new LobCreatorBuilderImpl( false );
|
return new LobCreatorBuilderImpl( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Class[] NO_ARG_SIG = ArrayHelper.EMPTY_CLASS_ARRAY;
|
private static final Class<?>[] NO_ARG_SIG = ArrayHelper.EMPTY_CLASS_ARRAY;
|
||||||
private static final Object[] NO_ARGS = ArrayHelper.EMPTY_OBJECT_ARRAY;
|
private static final Object[] NO_ARGS = ArrayHelper.EMPTY_OBJECT_ARRAY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,8 +82,7 @@ public class LobCreatorBuilderImpl implements LobCreatorBuilder {
|
||||||
*
|
*
|
||||||
* @return True if the connection can be used to create LOBs; false otherwise.
|
* @return True if the connection can be used to create LOBs; false otherwise.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
private static boolean useContextualLobCreation(Dialect dialect, Map<String,Object> configValues, Connection jdbcConnection) {
|
||||||
private static boolean useContextualLobCreation(Dialect dialect, Map configValues, Connection jdbcConnection) {
|
|
||||||
final boolean isNonContextualLobCreationRequired =
|
final boolean isNonContextualLobCreationRequired =
|
||||||
ConfigurationHelper.getBoolean( Environment.NON_CONTEXTUAL_LOB_CREATION, configValues );
|
ConfigurationHelper.getBoolean( Environment.NON_CONTEXTUAL_LOB_CREATION, configValues );
|
||||||
if ( isNonContextualLobCreationRequired ) {
|
if ( isNonContextualLobCreationRequired ) {
|
||||||
|
@ -112,20 +111,20 @@ public class LobCreatorBuilderImpl implements LobCreatorBuilder {
|
||||||
// ignore exception and continue
|
// ignore exception and continue
|
||||||
}
|
}
|
||||||
|
|
||||||
final Class connectionClass = Connection.class;
|
final Class<?> connectionClass = Connection.class;
|
||||||
final Method createClobMethod = connectionClass.getMethod( "createClob", NO_ARG_SIG );
|
final Method createClobMethod = connectionClass.getMethod( "createClob", NO_ARG_SIG );
|
||||||
if ( createClobMethod.getDeclaringClass().equals( Connection.class ) ) {
|
if ( createClobMethod.getDeclaringClass().equals( Connection.class ) ) {
|
||||||
// If we get here we are running in a jdk 1.6 (jdbc 4) environment...
|
// If we get here we are running in a jdk 1.6 (jdbc 4) environment:
|
||||||
// Further check to make sure the driver actually implements the LOB creation methods. We
|
// Further check to make sure the driver actually implements the LOB creation methods.
|
||||||
// check against createClob() as indicative of all; should we check against all 3 explicitly?
|
// We check against createClob() as indicative of all; should we check against all 3 explicitly?
|
||||||
try {
|
try {
|
||||||
final Object clob = createClobMethod.invoke( jdbcConnection, NO_ARGS );
|
final Object clob = createClobMethod.invoke( jdbcConnection, NO_ARGS );
|
||||||
try {
|
try {
|
||||||
final Method freeMethod = clob.getClass().getMethod( "free", NO_ARG_SIG );
|
final Method freeMethod = clob.getClass().getMethod( "free", NO_ARG_SIG );
|
||||||
freeMethod.invoke( clob, NO_ARGS );
|
freeMethod.invoke( clob, NO_ARGS );
|
||||||
}
|
}
|
||||||
catch ( Throwable ignore ) {
|
catch ( Throwable e ) {
|
||||||
LOG.tracef( "Unable to free CLOB created to test createClob() implementation : %s", ignore );
|
LOG.tracef( "Unable to free CLOB created to test createClob() implementation : %s", e );
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,8 @@
|
||||||
package org.hibernate.engine.jdbc.env.spi;
|
package org.hibernate.engine.jdbc.env.spi;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.hibernate.engine.jdbc.spi.TypeInfo;
|
|
||||||
import org.hibernate.tool.schema.extract.spi.SequenceInformation;
|
import org.hibernate.tool.schema.extract.spi.SequenceInformation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +18,6 @@ import org.hibernate.tool.schema.extract.spi.SequenceInformation;
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings( {"UnusedDeclaration"})
|
|
||||||
public interface ExtractedDatabaseMetaData {
|
public interface ExtractedDatabaseMetaData {
|
||||||
/**
|
/**
|
||||||
* Obtain the JDBC Environment from which this metadata came.
|
* Obtain the JDBC Environment from which this metadata came.
|
||||||
|
|
|
@ -9,7 +9,6 @@ package org.hibernate.engine.jdbc.env.spi;
|
||||||
import org.hibernate.boot.model.naming.Identifier;
|
import org.hibernate.boot.model.naming.Identifier;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
|
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
|
||||||
import org.hibernate.engine.jdbc.spi.TypeInfo;
|
|
||||||
import org.hibernate.service.Service;
|
import org.hibernate.service.Service;
|
||||||
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
|
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ public final class HighlightingFormatter implements Formatter {
|
||||||
|
|
||||||
private static String escape(String code) {
|
private static String escape(String code) {
|
||||||
return "\u001b[" + code + "m";
|
return "\u001b[" + code + "m";
|
||||||
};
|
}
|
||||||
|
|
||||||
private final String keywordEscape;
|
private final String keywordEscape;
|
||||||
private final String stringEscape;
|
private final String stringEscape;
|
||||||
|
|
|
@ -53,10 +53,10 @@ import org.hibernate.resource.transaction.backend.jdbc.spi.JdbcResourceTransacti
|
||||||
public class JdbcCoordinatorImpl implements JdbcCoordinator {
|
public class JdbcCoordinatorImpl implements JdbcCoordinator {
|
||||||
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( JdbcCoordinatorImpl.class );
|
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( JdbcCoordinatorImpl.class );
|
||||||
|
|
||||||
private transient LogicalConnectionImplementor logicalConnection;
|
private transient final LogicalConnectionImplementor logicalConnection;
|
||||||
private transient JdbcSessionOwner owner;
|
private transient final JdbcSessionOwner owner;
|
||||||
|
|
||||||
private transient JdbcServices jdbcServices;
|
private transient final JdbcServices jdbcServices;
|
||||||
|
|
||||||
private transient Batch currentBatch;
|
private transient Batch currentBatch;
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTransactionTimeOut(int seconds) {
|
public void setTransactionTimeOut(int seconds) {
|
||||||
transactionTimeOutInstant = System.currentTimeMillis() + ( seconds * 1000 );
|
transactionTimeOutInstant = System.currentTimeMillis() + ( seconds * 1000L );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -339,7 +339,7 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator {
|
||||||
catch (SQLException sqle) {
|
catch (SQLException sqle) {
|
||||||
SqlExceptionHelper sqlExceptionHelper = jdbcServices.getSqlExceptionHelper();
|
SqlExceptionHelper sqlExceptionHelper = jdbcServices.getSqlExceptionHelper();
|
||||||
//Should always be non-null, but to make sure as the implementation is lazy:
|
//Should always be non-null, but to make sure as the implementation is lazy:
|
||||||
if ( sqlExceptionHelper != null ) {
|
if ( sqlExceptionHelper == null ) {
|
||||||
sqlExceptionHelper = new SqlExceptionHelper( false );
|
sqlExceptionHelper = new SqlExceptionHelper( false );
|
||||||
}
|
}
|
||||||
throw sqlExceptionHelper.convert( sqle, "Cannot cancel query" );
|
throw sqlExceptionHelper.convert( sqle, "Cannot cancel query" );
|
||||||
|
@ -398,20 +398,17 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator {
|
||||||
lastQuery = null;
|
lastQuery = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( SQLException e ) {
|
|
||||||
LOG.debugf( "Unable to release JDBC statement [%s]", e.getMessage() );
|
|
||||||
}
|
|
||||||
catch ( Exception e ) {
|
catch ( Exception e ) {
|
||||||
// try to handle general errors more elegantly
|
|
||||||
LOG.debugf( "Unable to release JDBC statement [%s]", e.getMessage() );
|
LOG.debugf( "Unable to release JDBC statement [%s]", e.getMessage() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
|
||||||
protected void close(ResultSet resultSet) {
|
protected void close(ResultSet resultSet) {
|
||||||
LOG.tracev( "Closing result set [{0}]", resultSet );
|
LOG.tracev( "Closing result set [{0}]", resultSet );
|
||||||
|
|
||||||
if ( resultSet instanceof InvalidatableWrapper ) {
|
if ( resultSet instanceof InvalidatableWrapper ) {
|
||||||
|
@SuppressWarnings({ "unchecked" })
|
||||||
final InvalidatableWrapper<ResultSet> wrapper = (InvalidatableWrapper<ResultSet>) resultSet;
|
final InvalidatableWrapper<ResultSet> wrapper = (InvalidatableWrapper<ResultSet>) resultSet;
|
||||||
close( wrapper.getWrappedObject() );
|
close( wrapper.getWrappedObject() );
|
||||||
wrapper.invalidate();
|
wrapper.invalidate();
|
||||||
|
@ -421,9 +418,6 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator {
|
||||||
try {
|
try {
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
}
|
}
|
||||||
catch( SQLException e ) {
|
|
||||||
LOG.debugf( "Unable to release JDBC result set [%s]", e.getMessage() );
|
|
||||||
}
|
|
||||||
catch ( Exception e ) {
|
catch ( Exception e ) {
|
||||||
// try to handle general errors more elegantly
|
// try to handle general errors more elegantly
|
||||||
LOG.debugf( "Unable to release JDBC result set [%s]", e.getMessage() );
|
LOG.debugf( "Unable to release JDBC result set [%s]", e.getMessage() );
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.sql.Connection;
|
||||||
import java.sql.DatabaseMetaData;
|
import java.sql.DatabaseMetaData;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.engine.jdbc.ContextualLobCreator;
|
import org.hibernate.engine.jdbc.ContextualLobCreator;
|
||||||
|
@ -18,6 +19,7 @@ import org.hibernate.engine.jdbc.LobCreationContext;
|
||||||
import org.hibernate.engine.jdbc.LobCreator;
|
import org.hibernate.engine.jdbc.LobCreator;
|
||||||
import org.hibernate.engine.jdbc.NonContextualLobCreator;
|
import org.hibernate.engine.jdbc.NonContextualLobCreator;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
|
import org.hibernate.internal.util.PropertiesHelper;
|
||||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||||
|
|
||||||
|
@ -34,20 +36,24 @@ public class LobCreatorBuilder {
|
||||||
LobCreatorBuilder.class.getName()
|
LobCreatorBuilder.class.getName()
|
||||||
);
|
);
|
||||||
|
|
||||||
private boolean useContextualLobCreation;
|
private final boolean useContextualLobCreation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The public factory method for obtaining the appropriate (according to given JDBC {@link Connection}.
|
* The public factory method for obtaining the appropriate according to given JDBC {@link Connection}.
|
||||||
*
|
*
|
||||||
* @param configValues The map of settings
|
* @param configValues The map of settings
|
||||||
* @param jdbcConnection A JDBC {@link Connection} which can be used to gauge the drivers level of support,
|
* @param jdbcConnection A JDBC {@link Connection} which can be used to gauge the drivers level of support,
|
||||||
* specifically for creating LOB references.
|
* specifically for creating LOB references.
|
||||||
*/
|
*/
|
||||||
public LobCreatorBuilder(Map configValues, Connection jdbcConnection) {
|
public LobCreatorBuilder(Map<String,Object> configValues, Connection jdbcConnection) {
|
||||||
this.useContextualLobCreation = useContextualLobCreation( configValues, jdbcConnection );
|
this.useContextualLobCreation = useContextualLobCreation( configValues, jdbcConnection );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Class[] NO_ARG_SIG = ArrayHelper.EMPTY_CLASS_ARRAY;
|
public LobCreatorBuilder(Properties configValues, Connection jdbcConnection) {
|
||||||
|
this( PropertiesHelper.map(configValues), jdbcConnection );
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Class<?>[] NO_ARG_SIG = ArrayHelper.EMPTY_CLASS_ARRAY;
|
||||||
private static final Object[] NO_ARGS = ArrayHelper.EMPTY_OBJECT_ARRAY;
|
private static final Object[] NO_ARGS = ArrayHelper.EMPTY_OBJECT_ARRAY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,8 +66,7 @@ public class LobCreatorBuilder {
|
||||||
*
|
*
|
||||||
* @return True if the connection can be used to create LOBs; false otherwise.
|
* @return True if the connection can be used to create LOBs; false otherwise.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
private static boolean useContextualLobCreation(Map<String,Object> configValues, Connection jdbcConnection) {
|
||||||
private static boolean useContextualLobCreation(Map configValues, Connection jdbcConnection) {
|
|
||||||
final boolean isNonContextualLobCreationRequired =
|
final boolean isNonContextualLobCreationRequired =
|
||||||
ConfigurationHelper.getBoolean( Environment.NON_CONTEXTUAL_LOB_CREATION, configValues );
|
ConfigurationHelper.getBoolean( Environment.NON_CONTEXTUAL_LOB_CREATION, configValues );
|
||||||
if ( isNonContextualLobCreationRequired ) {
|
if ( isNonContextualLobCreationRequired ) {
|
||||||
|
@ -86,20 +91,20 @@ public class LobCreatorBuilder {
|
||||||
// ignore exception and continue
|
// ignore exception and continue
|
||||||
}
|
}
|
||||||
|
|
||||||
final Class connectionClass = Connection.class;
|
final Class<Connection> connectionClass = Connection.class;
|
||||||
final Method createClobMethod = connectionClass.getMethod( "createClob", NO_ARG_SIG );
|
final Method createClobMethod = connectionClass.getMethod( "createClob", NO_ARG_SIG );
|
||||||
if ( createClobMethod.getDeclaringClass().equals( Connection.class ) ) {
|
if ( createClobMethod.getDeclaringClass().equals( Connection.class ) ) {
|
||||||
// If we get here we are running in a jdk 1.6 (jdbc 4) environment...
|
// If we get here we are running in a jdk 1.6 (jdbc 4) environment:
|
||||||
// Further check to make sure the driver actually implements the LOB creation methods. We
|
// Further check to make sure the driver actually implements the LOB creation methods.
|
||||||
// check against createClob() as indicative of all; should we check against all 3 explicitly?
|
// We check against createClob() as indicative of all; should we check against all 3 explicitly?
|
||||||
try {
|
try {
|
||||||
final Object clob = createClobMethod.invoke( jdbcConnection, NO_ARGS );
|
final Object clob = createClobMethod.invoke( jdbcConnection, NO_ARGS );
|
||||||
try {
|
try {
|
||||||
final Method freeMethod = clob.getClass().getMethod( "free", NO_ARG_SIG );
|
final Method freeMethod = clob.getClass().getMethod( "free", NO_ARG_SIG );
|
||||||
freeMethod.invoke( clob, NO_ARGS );
|
freeMethod.invoke( clob, NO_ARGS );
|
||||||
}
|
}
|
||||||
catch ( Throwable ignore ) {
|
catch ( Throwable e ) {
|
||||||
LOG.tracef( "Unable to free CLOB created to test createClob() implementation : %s", ignore );
|
LOG.tracef( "Unable to free CLOB created to test createClob() implementation : %s", e );
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ package org.hibernate.engine.jdbc.spi;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A no-op adapter for ConnectionObserver.
|
* A no-op adapter for {@link ConnectionObserver}.
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -8,7 +8,7 @@ package org.hibernate.engine.jdbc.spi;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specialized {@link JdbcWrapper} contract for wrapped objects that can additioanlly be invalidated
|
* Specialized {@link JdbcWrapper} contract for wrapped objects that can additionally be invalidated
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
package org.hibernate.engine.jdbc.spi;
|
package org.hibernate.engine.jdbc.spi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additional optional contract for connection observers to indicate that they should be released when the physical
|
* Additional optional contract for connection observers to indicate that
|
||||||
* connection is released.
|
* they should be released when the physical connection is released.
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -21,7 +21,6 @@ import org.jboss.logging.Logger;
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("UnusedDeclaration")
|
|
||||||
public class TypeInfo {
|
public class TypeInfo {
|
||||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
|
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
|
||||||
CoreMessageLogger.class,
|
CoreMessageLogger.class,
|
||||||
|
|
|
@ -9,7 +9,7 @@ package org.hibernate.engine.jdbc.spi;
|
||||||
import java.sql.DatabaseMetaData;
|
import java.sql.DatabaseMetaData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes the instrinsic nullability of a data type as reported by the JDBC driver.
|
* Describes the intrinsic nullability of a data type as reported by the JDBC driver.
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -126,7 +126,7 @@ public class LobCreatorTest extends org.hibernate.testing.junit4.BaseUnitTestCas
|
||||||
else {
|
else {
|
||||||
assertTrue( nclob instanceof JdbcNClob );
|
assertTrue( nclob instanceof JdbcNClob );
|
||||||
}
|
}
|
||||||
assertTrue( NClob.class.isInstance( nclob ) );
|
// assertTrue( nclob instanceof NClob );
|
||||||
nclob = lobCreator.wrap( nclob );
|
nclob = lobCreator.wrap( nclob );
|
||||||
assertTrue( nclob instanceof WrappedClob );
|
assertTrue( nclob instanceof WrappedClob );
|
||||||
|
|
||||||
|
@ -135,8 +135,8 @@ public class LobCreatorTest extends org.hibernate.testing.junit4.BaseUnitTestCas
|
||||||
nclob.free();
|
nclob.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LobCreationContextImpl implements LobCreationContext {
|
private static class LobCreationContextImpl implements LobCreationContext {
|
||||||
private Connection connection;
|
private final Connection connection;
|
||||||
|
|
||||||
private LobCreationContextImpl(Connection connection) {
|
private LobCreationContextImpl(Connection connection) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
|
@ -153,12 +153,12 @@ public class LobCreatorTest extends org.hibernate.testing.junit4.BaseUnitTestCas
|
||||||
}
|
}
|
||||||
|
|
||||||
private interface JdbcLobBuilder {
|
private interface JdbcLobBuilder {
|
||||||
public Blob createBlob() throws SQLException ;
|
Blob createBlob() throws SQLException ;
|
||||||
public Clob createClob() throws SQLException ;
|
Clob createClob() throws SQLException ;
|
||||||
public NClob createNClob() throws SQLException ;
|
NClob createNClob() throws SQLException ;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class JdbcLobBuilderImpl implements JdbcLobBuilder {
|
private static class JdbcLobBuilderImpl implements JdbcLobBuilder {
|
||||||
private final boolean isSupported;
|
private final boolean isSupported;
|
||||||
|
|
||||||
private JdbcLobBuilderImpl(boolean isSupported) {
|
private JdbcLobBuilderImpl(boolean isSupported) {
|
||||||
|
@ -199,16 +199,14 @@ public class LobCreatorTest extends org.hibernate.testing.junit4.BaseUnitTestCas
|
||||||
// the only methods we are interested in are the LOB creation methods...
|
// the only methods we are interested in are the LOB creation methods...
|
||||||
if ( args == null || args.length == 0 ) {
|
if ( args == null || args.length == 0 ) {
|
||||||
final String methodName = method.getName();
|
final String methodName = method.getName();
|
||||||
if ( "createBlob".equals( methodName ) ) {
|
switch (methodName) {
|
||||||
|
case "createBlob":
|
||||||
return lobBuilder.createBlob();
|
return lobBuilder.createBlob();
|
||||||
}
|
case "createClob":
|
||||||
else if ( "createClob".equals( methodName ) ) {
|
|
||||||
return lobBuilder.createClob();
|
return lobBuilder.createClob();
|
||||||
}
|
case "createNClob":
|
||||||
else if ( "createNClob".equals( methodName ) ) {
|
|
||||||
return lobBuilder.createNClob();
|
return lobBuilder.createNClob();
|
||||||
}
|
case "getMetaData":
|
||||||
else if ( "getMetaData".equals( methodName ) ) {
|
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,14 +214,14 @@ public class LobCreatorTest extends org.hibernate.testing.junit4.BaseUnitTestCas
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Class[] CONN_PROXY_TYPES = new Class[] { Connection.class };
|
private static final Class<?>[] CONN_PROXY_TYPES = new Class[] { Connection.class };
|
||||||
|
|
||||||
private Connection createConnectionProxy(int version, JdbcLobBuilder jdbcLobBuilder) {
|
private Connection createConnectionProxy(int version, JdbcLobBuilder jdbcLobBuilder) {
|
||||||
ConnectionProxyHandler handler = new ConnectionProxyHandler( version, jdbcLobBuilder );
|
ConnectionProxyHandler handler = new ConnectionProxyHandler( version, jdbcLobBuilder );
|
||||||
return ( Connection ) Proxy.newProxyInstance( getClass().getClassLoader(), CONN_PROXY_TYPES, handler );
|
return ( Connection ) Proxy.newProxyInstance( getClass().getClassLoader(), CONN_PROXY_TYPES, handler );
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MetadataProxyHandler implements InvocationHandler {
|
private static class MetadataProxyHandler implements InvocationHandler {
|
||||||
private final int jdbcVersion;
|
private final int jdbcVersion;
|
||||||
|
|
||||||
private MetadataProxyHandler(int jdbcVersion) {
|
private MetadataProxyHandler(int jdbcVersion) {
|
||||||
|
@ -239,14 +237,14 @@ public class LobCreatorTest extends org.hibernate.testing.junit4.BaseUnitTestCas
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Class[] META_PROXY_TYPES = new Class[] { DatabaseMetaData.class };
|
private static final Class<?>[] META_PROXY_TYPES = new Class[] { DatabaseMetaData.class };
|
||||||
|
|
||||||
private DatabaseMetaData createMetadataProxy(int version) {
|
private DatabaseMetaData createMetadataProxy(int version) {
|
||||||
MetadataProxyHandler handler = new MetadataProxyHandler( version );
|
MetadataProxyHandler handler = new MetadataProxyHandler( version );
|
||||||
return ( DatabaseMetaData ) Proxy.newProxyInstance( getClass().getClassLoader(), META_PROXY_TYPES, handler );
|
return ( DatabaseMetaData ) Proxy.newProxyInstance( getClass().getClassLoader(), META_PROXY_TYPES, handler );
|
||||||
}
|
}
|
||||||
|
|
||||||
private class JdbcBlob implements Blob {
|
private static class JdbcBlob implements Blob {
|
||||||
public long length() throws SQLException {
|
public long length() throws SQLException {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -255,7 +253,7 @@ public class LobCreatorTest extends org.hibernate.testing.junit4.BaseUnitTestCas
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream getBinaryStream() throws SQLException {
|
public InputStream getBinaryStream() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,35 +273,35 @@ public class LobCreatorTest extends org.hibernate.testing.junit4.BaseUnitTestCas
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OutputStream setBinaryStream(long pos) throws SQLException {
|
public OutputStream setBinaryStream(long pos) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void truncate(long len) throws SQLException {
|
public void truncate(long len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void free() throws SQLException {
|
public void free() throws SQLException {
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream getBinaryStream(long pos, long length) throws SQLException {
|
public InputStream getBinaryStream(long pos, long length) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class JdbcClob implements Clob {
|
private static class JdbcClob implements Clob {
|
||||||
public long length() throws SQLException {
|
public long length() throws SQLException {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSubString(long pos, int length) throws SQLException {
|
public String getSubString(long pos, int length) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Reader getCharacterStream() throws SQLException {
|
public Reader getCharacterStream() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream getAsciiStream() throws SQLException {
|
public InputStream getAsciiStream() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,25 +321,25 @@ public class LobCreatorTest extends org.hibernate.testing.junit4.BaseUnitTestCas
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OutputStream setAsciiStream(long pos) throws SQLException {
|
public OutputStream setAsciiStream(long pos) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Writer setCharacterStream(long pos) throws SQLException {
|
public Writer setCharacterStream(long pos) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void truncate(long len) throws SQLException {
|
public void truncate(long len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void free() throws SQLException {
|
public void free() throws SQLException {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Reader getCharacterStream(long pos, long length) throws SQLException {
|
public Reader getCharacterStream(long pos, long length) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class JdbcNClob extends JdbcClob implements NClob {
|
private static class JdbcNClob extends JdbcClob implements NClob {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@ public class JtaWithFailingBatchTest extends AbstractJtaBatchTest {
|
||||||
|
|
||||||
public static class TestBatch extends BatchingBatch {
|
public static class TestBatch extends BatchingBatch {
|
||||||
private int numberOfStatementsAfterReleasing;
|
private int numberOfStatementsAfterReleasing;
|
||||||
private List<PreparedStatement> createdStatements = new ArrayList<>();
|
private final List<PreparedStatement> createdStatements = new ArrayList<>();
|
||||||
private boolean calledReleaseStatements;
|
private boolean calledReleaseStatements;
|
||||||
|
|
||||||
private String currentStatementSql;
|
private String currentStatementSql;
|
||||||
|
|
Loading…
Reference in New Issue