HHH-5623 - Baseline on JDK 1.6
This commit is contained in:
parent
1d8c9f5d6c
commit
28a6acdcda
|
@ -115,10 +115,6 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<compilerVersion>1.6</compilerVersion>
|
||||
<executable>${jdk16_home}/bin/javac</executable>
|
||||
<fork>true</fork>
|
||||
<verbose>true</verbose>
|
||||
</configuration>
|
||||
|
@ -127,7 +123,6 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<jvm>${jdk16_home}/bin/java</jvm>
|
||||
<excludes>
|
||||
<!-- Skip a long-running test of a prototype class -->
|
||||
<exclude>**/ClusteredConcurrentTimestampRegionTestCase.java</exclude>
|
||||
|
|
|
@ -92,14 +92,6 @@
|
|||
</testResources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
|
|
|
@ -23,12 +23,6 @@
|
|||
*/
|
||||
package org.hibernate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.sql.Blob;
|
||||
import java.sql.Clob;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -36,13 +30,10 @@ import org.hibernate.collection.PersistentCollection;
|
|||
import org.hibernate.engine.HibernateIterator;
|
||||
import org.hibernate.engine.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.SessionImplementor;
|
||||
import org.hibernate.engine.jdbc.NonContextualLobCreator;
|
||||
import org.hibernate.engine.jdbc.LobCreationContext;
|
||||
import org.hibernate.engine.jdbc.LobCreator;
|
||||
import org.hibernate.engine.jdbc.StreamUtils;
|
||||
import org.hibernate.intercept.FieldInterceptionHelper;
|
||||
import org.hibernate.intercept.FieldInterceptor;
|
||||
import org.hibernate.mapping.ManyToOne;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
import org.hibernate.proxy.LazyInitializer;
|
||||
import org.hibernate.type.AnyType;
|
||||
|
@ -54,6 +45,8 @@ import org.hibernate.type.BooleanType;
|
|||
import org.hibernate.type.ByteType;
|
||||
import org.hibernate.type.CalendarDateType;
|
||||
import org.hibernate.type.CalendarType;
|
||||
import org.hibernate.type.CharArrayType;
|
||||
import org.hibernate.type.CharacterArrayType;
|
||||
import org.hibernate.type.CharacterType;
|
||||
import org.hibernate.type.ClassType;
|
||||
import org.hibernate.type.ClobType;
|
||||
|
@ -61,10 +54,13 @@ import org.hibernate.type.CurrencyType;
|
|||
import org.hibernate.type.DateType;
|
||||
import org.hibernate.type.DoubleType;
|
||||
import org.hibernate.type.FloatType;
|
||||
import org.hibernate.type.ImageType;
|
||||
import org.hibernate.type.IntegerType;
|
||||
import org.hibernate.type.LocaleType;
|
||||
import org.hibernate.type.LongType;
|
||||
import org.hibernate.type.ManyToOneType;
|
||||
import org.hibernate.type.MaterializedBlobType;
|
||||
import org.hibernate.type.MaterializedClobType;
|
||||
import org.hibernate.type.ObjectType;
|
||||
import org.hibernate.type.SerializableType;
|
||||
import org.hibernate.type.ShortType;
|
||||
|
@ -76,13 +72,8 @@ import org.hibernate.type.TimestampType;
|
|||
import org.hibernate.type.TrueFalseType;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.TypeFactory;
|
||||
import org.hibernate.type.YesNoType;
|
||||
import org.hibernate.type.CharArrayType;
|
||||
import org.hibernate.type.WrapperBinaryType;
|
||||
import org.hibernate.type.CharacterArrayType;
|
||||
import org.hibernate.type.MaterializedBlobType;
|
||||
import org.hibernate.type.ImageType;
|
||||
import org.hibernate.type.MaterializedClobType;
|
||||
import org.hibernate.type.YesNoType;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
|
||||
/**
|
||||
|
@ -434,31 +425,6 @@ public final class Hibernate {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Blob}. The returned object will be initially immutable.
|
||||
*
|
||||
* @param bytes a byte array
|
||||
* @return the Blob
|
||||
* @deprecated Use {@link LobHelper#createBlob(byte[])} instead.
|
||||
*/
|
||||
public static Blob createBlob(byte[] bytes) {
|
||||
return NonContextualLobCreator.INSTANCE.wrap(
|
||||
NonContextualLobCreator.INSTANCE.createBlob( bytes )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Blob}.
|
||||
*
|
||||
* @param bytes a byte array
|
||||
* @param session The session in which the {@link Blob} will be used.
|
||||
* @return the Blob
|
||||
* @deprecated Use {@link LobHelper#createBlob(byte[])} instead.
|
||||
*/
|
||||
public static Blob createBlob(byte[] bytes, Session session) {
|
||||
return getLobCreator( session ).createBlob( bytes );
|
||||
}
|
||||
|
||||
public static LobCreator getLobCreator(Session session) {
|
||||
return getLobCreator( ( SessionImplementor ) session );
|
||||
}
|
||||
|
@ -470,140 +436,6 @@ public final class Hibernate {
|
|||
.getLobCreator( ( LobCreationContext ) session );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Blob}. The returned object will be initially immutable.
|
||||
*
|
||||
* @param stream a binary stream
|
||||
* @param length the number of bytes in the stream
|
||||
* @return the Blob
|
||||
* @deprecated Use {@link LobHelper#createBlob(InputStream, long)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static Blob createBlob(InputStream stream, int length) {
|
||||
return NonContextualLobCreator.INSTANCE.wrap(
|
||||
NonContextualLobCreator.INSTANCE.createBlob( stream, length )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Blob}. The returned object will be initially immutable.
|
||||
*
|
||||
* @param stream a binary stream
|
||||
* @param length the number of bytes in the stream
|
||||
* @return the Blob
|
||||
* @deprecated Use {@link LobHelper#createBlob(InputStream, long)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static Blob createBlob(InputStream stream, long length) {
|
||||
return NonContextualLobCreator.INSTANCE.wrap(
|
||||
NonContextualLobCreator.INSTANCE.createBlob( stream, length )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Blob}.
|
||||
*
|
||||
* @param stream a binary stream
|
||||
* @param length the number of bytes in the stream
|
||||
* @param session The session in which the {@link Blob} will be used.
|
||||
* @return the Blob
|
||||
* @deprecated Use {@link LobHelper#createBlob(InputStream, long)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static Blob createBlob(InputStream stream, long length, Session session) {
|
||||
return getLobCreator( session ).createBlob( stream, length );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Blob}. The returned object will be initially immutable.
|
||||
* <p/>
|
||||
* NOTE: this method will read the entire contents of the incoming stream in order to properly
|
||||
* handle the {@link Blob#length()} method. If you do not want the stream read, use the
|
||||
* {@link #createBlob(InputStream,long)} version instead.
|
||||
*
|
||||
* @param stream a binary stream
|
||||
* @return the Blob
|
||||
* @throws IOException Indicates an I/O problem accessing the stream
|
||||
* @deprecated With no direct replacement. Use {@link #createBlob(InputStream,long)} instead, passing in the length
|
||||
*/
|
||||
@Deprecated
|
||||
public static Blob createBlob(InputStream stream) throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream( stream.available() );
|
||||
StreamUtils.copy( stream, buffer );
|
||||
return createBlob( buffer.toByteArray() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Clob}. The returned object will be initially immutable.
|
||||
*
|
||||
* @param string The string data
|
||||
* @return The created {@link Clob}
|
||||
* @deprecated Use {@link LobHelper#createClob(String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static Clob createClob(String string) {
|
||||
return NonContextualLobCreator.INSTANCE.wrap(
|
||||
NonContextualLobCreator.INSTANCE.createClob( string )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Clob}.
|
||||
*
|
||||
* @param string The string data
|
||||
* @param session The session in which the {@link Clob} will be used.
|
||||
* @return The created {@link Clob}
|
||||
* @deprecated Use {@link LobHelper#createClob(String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static Clob createClob(String string, Session session) {
|
||||
return getLobCreator( session ).createClob( string );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Clob}. The returned object will be initially immutable.
|
||||
*
|
||||
* @param reader a character stream
|
||||
* @param length the number of characters in the stream
|
||||
* @return The created {@link Clob}
|
||||
* @deprecated Use {@link LobHelper#createClob(Reader, long)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static Clob createClob(Reader reader, int length) {
|
||||
return NonContextualLobCreator.INSTANCE.wrap(
|
||||
NonContextualLobCreator.INSTANCE.createClob( reader, length )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Clob}. The returned object will be initially immutable.
|
||||
*
|
||||
* @param reader a character stream
|
||||
* @param length the number of characters in the stream
|
||||
* @return The created {@link Clob}
|
||||
* @deprecated Use {@link LobHelper#createClob(Reader, long)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static Clob createClob(Reader reader, long length) {
|
||||
return NonContextualLobCreator.INSTANCE.wrap(
|
||||
NonContextualLobCreator.INSTANCE.createClob( reader, length )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Clob}.
|
||||
*
|
||||
* @param reader a character stream
|
||||
* @param length the number of characters in the stream
|
||||
* @param session The session in which the {@link Clob} will be used.
|
||||
* @return The created {@link Clob}
|
||||
* @deprecated Use {@link LobHelper#createClob(Reader, long)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static Clob createClob(Reader reader, long length, Session session) {
|
||||
return getLobCreator( session ).createClob( reader, length );
|
||||
}
|
||||
|
||||
/**
|
||||
* Close an <tt>Iterator</tt> created by <tt>iterate()</tt> immediately,
|
||||
* instead of waiting until the session is closed or disconnected.
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
package org.hibernate.cfg;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.ResultSet;
|
||||
|
@ -39,7 +38,6 @@ import org.hibernate.ConnectionReleaseMode;
|
|||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.jdbc.JdbcSupport;
|
||||
import org.hibernate.engine.jdbc.JdbcSupportLoader;
|
||||
import org.hibernate.bytecode.BytecodeProvider;
|
||||
import org.hibernate.cache.QueryCacheFactory;
|
||||
import org.hibernate.cache.RegionFactory;
|
||||
|
@ -99,7 +97,6 @@ public class SettingsFactory implements Serializable {
|
|||
boolean metaReportsDDLCausesTxnCommit = false;
|
||||
boolean metaReportsDDLInTxnSupported = true;
|
||||
Dialect dialect = null;
|
||||
JdbcSupport jdbcSupport = null;
|
||||
|
||||
// 'hibernate.temp.use_jdbc_metadata_defaults' is a temporary magic value.
|
||||
// The need for it is intended to be alleviated with future development, thus it is
|
||||
|
@ -128,7 +125,6 @@ public class SettingsFactory implements Serializable {
|
|||
);
|
||||
|
||||
dialect = DialectFactory.buildDialect( props, conn );
|
||||
jdbcSupport = JdbcSupportLoader.loadJdbcSupport( conn );
|
||||
|
||||
metaSupportsScrollable = meta.supportsResultSetType( ResultSet.TYPE_SCROLL_INSENSITIVE );
|
||||
metaSupportsBatchUpdates = meta.supportsBatchUpdates();
|
||||
|
@ -159,10 +155,7 @@ public class SettingsFactory implements Serializable {
|
|||
settings.setDataDefinitionImplicitCommit( metaReportsDDLCausesTxnCommit );
|
||||
settings.setDataDefinitionInTransactionSupported( metaReportsDDLInTxnSupported );
|
||||
settings.setDialect( dialect );
|
||||
if ( jdbcSupport == null ) {
|
||||
jdbcSupport = JdbcSupportLoader.loadJdbcSupport( null );
|
||||
}
|
||||
settings.setJdbcSupport( jdbcSupport );
|
||||
settings.setJdbcSupport( new JdbcSupport() );
|
||||
|
||||
//use dialect default properties
|
||||
final Properties properties = new Properties();
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
|
||||
* third-party contributors as indicated by either @author tags or express
|
||||
* copyright attribution statements applied by the authors. All
|
||||
* third-party contributions are distributed under license by Red Hat Inc.
|
||||
* Copyright (c) 2010, 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 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
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
package org.hibernate.engine.jdbc;
|
||||
|
||||
import java.sql.Blob;
|
||||
import java.sql.NClob;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Clob;
|
||||
import java.sql.Connection;
|
||||
|
@ -32,8 +33,6 @@ import java.io.OutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.JDBCException;
|
||||
|
@ -58,7 +57,7 @@ public class ContextualLobCreator extends AbstractLobCreator implements LobCreat
|
|||
* @return The created BLOB reference.
|
||||
*/
|
||||
public Blob createBlob() {
|
||||
return ( Blob ) lobCreationContext.execute( CREATE_BLOB_CALLBACK );
|
||||
return lobCreationContext.execute( CREATE_BLOB_CALLBACK );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,7 +101,7 @@ public class ContextualLobCreator extends AbstractLobCreator implements LobCreat
|
|||
* @return The created CLOB reference.
|
||||
*/
|
||||
public Clob createClob() {
|
||||
return ( Clob ) lobCreationContext.execute( CREATE_CLOB_CALLBACK );
|
||||
return lobCreationContext.execute( CREATE_CLOB_CALLBACK );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -144,18 +143,18 @@ public class ContextualLobCreator extends AbstractLobCreator implements LobCreat
|
|||
*
|
||||
* @return The created NCLOB reference.
|
||||
*/
|
||||
public Clob createNClob() {
|
||||
return ( Clob ) lobCreationContext.execute( CREATE_NCLOB_CALLBACK );
|
||||
public NClob createNClob() {
|
||||
return lobCreationContext.execute( CREATE_NCLOB_CALLBACK );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Clob createNClob(String string) {
|
||||
public NClob createNClob(String string) {
|
||||
try {
|
||||
Clob clob = createNClob();
|
||||
clob.setString( 1, string );
|
||||
return clob;
|
||||
NClob nclob = createNClob();
|
||||
nclob.setString( 1, string );
|
||||
return nclob;
|
||||
}
|
||||
catch ( SQLException e ) {
|
||||
throw new JDBCException( "Unable to set NCLOB string after creation", e );
|
||||
|
@ -165,14 +164,14 @@ public class ContextualLobCreator extends AbstractLobCreator implements LobCreat
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Clob createNClob(Reader reader, long length) {
|
||||
public NClob createNClob(Reader reader, long length) {
|
||||
try {
|
||||
Clob clob = createNClob();
|
||||
Writer writer = clob.setCharacterStream( 1 );
|
||||
NClob nclob = createNClob();
|
||||
Writer writer = nclob.setCharacterStream( 1 );
|
||||
StreamUtils.copy( reader, writer );
|
||||
writer.flush();
|
||||
writer.close();
|
||||
return clob;
|
||||
return nclob;
|
||||
}
|
||||
catch ( SQLException e ) {
|
||||
throw new JDBCException( "Unable to prepare NCLOB stream for writing", e );
|
||||
|
@ -182,57 +181,21 @@ public class ContextualLobCreator extends AbstractLobCreator implements LobCreat
|
|||
}
|
||||
}
|
||||
|
||||
public static final LobCreationContext.Callback<Blob> CREATE_BLOB_CALLBACK = new LobCreationContext.Callback<Blob>() {
|
||||
public Blob executeOnConnection(Connection connection) throws SQLException {
|
||||
return connection.createBlob();
|
||||
}
|
||||
};
|
||||
|
||||
private static final Class[] CREATION_METHOD_SIG = new Class[0];
|
||||
private static final Object[] CREATION_METHOD_ARGS = new Object[0];
|
||||
public static final LobCreationContext.Callback<Clob> CREATE_CLOB_CALLBACK = new LobCreationContext.Callback<Clob>() {
|
||||
public Clob executeOnConnection(Connection connection) throws SQLException {
|
||||
return connection.createClob();
|
||||
}
|
||||
};
|
||||
|
||||
private static final LobCreationContext.Callback CREATE_BLOB_CALLBACK;
|
||||
private static final LobCreationContext.Callback CREATE_CLOB_CALLBACK;
|
||||
private static final LobCreationContext.Callback CREATE_NCLOB_CALLBACK;
|
||||
|
||||
static {
|
||||
CREATE_BLOB_CALLBACK = new CallbackImpl( getConnectionlobCreationMethod( "createBlob" ) );
|
||||
CREATE_CLOB_CALLBACK = new CallbackImpl( getConnectionlobCreationMethod( "createClob" ) );
|
||||
CREATE_NCLOB_CALLBACK = new CallbackImpl( getConnectionlobCreationMethod( "createNClob" ) );
|
||||
}
|
||||
|
||||
private static class CallbackImpl implements LobCreationContext.Callback {
|
||||
private final Method creationMethod;
|
||||
|
||||
private CallbackImpl(Method creationMethod) {
|
||||
this.creationMethod = creationMethod;
|
||||
}
|
||||
|
||||
public Object executeOnConnection(Connection connection) throws SQLException {
|
||||
try {
|
||||
return creationMethod.invoke( connection, CREATION_METHOD_ARGS );
|
||||
}
|
||||
catch ( InvocationTargetException e ) {
|
||||
if ( e.getTargetException() instanceof SQLException ) {
|
||||
throw ( SQLException ) e.getTargetException();
|
||||
}
|
||||
else {
|
||||
throw new HibernateException( "Exception invoking " + creationMethod.getName(), e.getTargetException() );
|
||||
}
|
||||
}
|
||||
catch ( AbstractMethodError e ) {
|
||||
// this again is a big big error...
|
||||
throw new IllegalStateException( "Useable implementation of " + creationMethod.getName() + " not found." );
|
||||
}
|
||||
catch ( IllegalAccessException e ) {
|
||||
// this again is a big big error...
|
||||
throw new IllegalStateException( "Illegal access attempt on JDBC method " + creationMethod.getName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Method getConnectionlobCreationMethod(String methodName) {
|
||||
try {
|
||||
return Connection.class.getMethod( methodName, CREATION_METHOD_SIG );
|
||||
}
|
||||
catch ( NoSuchMethodException e ) {
|
||||
// this is a big big error if we get here and these methods are not part of the Connection interface...
|
||||
throw new IllegalStateException( "JDBC driver did not implement " + methodName);
|
||||
}
|
||||
public static final LobCreationContext.Callback<NClob> CREATE_NCLOB_CALLBACK = new LobCreationContext.Callback<NClob>() {
|
||||
public NClob executeOnConnection(Connection connection) throws SQLException {
|
||||
return connection.createNClob();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -26,40 +26,20 @@ package org.hibernate.engine.jdbc;
|
|||
import java.sql.ResultSet;
|
||||
|
||||
/**
|
||||
* Isolates Hibernate interactions with JDBC in terms of variations between JDBC 3 (JDK 1.4 and 1.5)
|
||||
* and JDBC 4 (JDK 1.6).
|
||||
* Central place for locating JDBC support elements.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface JdbcSupport {
|
||||
/**
|
||||
* Creates an instance of a {@link LobCreator} that does not use the underlying JDBC {@link java.sql.Connection}
|
||||
* to create LOBs.
|
||||
* <p/>
|
||||
* This method is here solely to support the older, now-deprecated method of creating LOBs via
|
||||
* the various {@link org.hibernate.Hibernate#createBlob} and {@link org.hibernate.Hibernate#createClob} methods on
|
||||
* {@link org.hibernate.Hibernate}.
|
||||
*
|
||||
* @return The LOB creator.
|
||||
* @deprecated Use {@link #getLobCreator(LobCreationContext)} instead.
|
||||
*/
|
||||
public LobCreator getLobCreator();
|
||||
public class JdbcSupport {
|
||||
public LobCreator getLobCreator() {
|
||||
return NonContextualLobCreator.INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of a {@link LobCreator} appropriate for the current environment, mainly meant to account for
|
||||
* variance between JDBC 4 (<= JDK 1.6) and JDBC3 (>= JDK 1.5).
|
||||
*
|
||||
* @param lobCreationContext The context in which the LOB is being created
|
||||
* @return The LOB creator.
|
||||
*/
|
||||
public LobCreator getLobCreator(LobCreationContext lobCreationContext);
|
||||
public LobCreator getLobCreator(LobCreationContext lobCreationContext) {
|
||||
return new ContextualLobCreator( lobCreationContext );
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap the given {@link ResultSet} in one that caches the column-name -> column-index resolution.
|
||||
*
|
||||
* @param resultSet The {@link ResultSet} to wrap.
|
||||
* @param columnNameCache The resolution cache.
|
||||
* @return The wrapper.
|
||||
*/
|
||||
public ResultSet wrap(ResultSet resultSet, ColumnNameCache columnNameCache);
|
||||
public ResultSet wrap(ResultSet resultSet, ColumnNameCache columnNameCache) {
|
||||
return ResultSetWrapperProxy.generateProxy( resultSet, columnNameCache );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
|
||||
* third-party contributors as indicated by either @author tags or express
|
||||
* copyright attribution statements applied by the authors. All
|
||||
* third-party contributions are 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
|
||||
* 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.engine.jdbc;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
|
||||
/**
|
||||
* TODO : javadoc
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class JdbcSupportImpl implements JdbcSupport {
|
||||
private final boolean useContextualLobCreation;
|
||||
|
||||
public JdbcSupportImpl(boolean useContextualLobCreation) {
|
||||
this.useContextualLobCreation = useContextualLobCreation;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public LobCreator getLobCreator() {
|
||||
return NonContextualLobCreator.INSTANCE;
|
||||
}
|
||||
|
||||
public LobCreator getLobCreator(LobCreationContext lobCreationContext) {
|
||||
if ( useContextualLobCreation ) {
|
||||
return new ContextualLobCreator( lobCreationContext );
|
||||
}
|
||||
else {
|
||||
return NonContextualLobCreator.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
public ResultSet wrap(ResultSet resultSet, ColumnNameCache columnNameCache) {
|
||||
return ResultSetWrapperProxy.generateProxy( resultSet, columnNameCache );
|
||||
}
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
|
||||
* third-party contributors as indicated by either @author tags or express
|
||||
* copyright attribution statements applied by the authors. All
|
||||
* third-party contributions are 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
|
||||
* 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.engine.jdbc;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Builds {@link JdbcSupport} instances based on the capabilities of the environment.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class JdbcSupportLoader {
|
||||
private static final Logger log = LoggerFactory.getLogger( JdbcSupportLoader.class );
|
||||
|
||||
/**
|
||||
* The public factory method for obtaining the appropriate (according to given JDBC {@link java.sql.Connection})
|
||||
* {@link JdbcSupport}.
|
||||
*
|
||||
* @param jdbcConnection A JDBC {@link java.sql.Connection} which can be used to gauge the drivers level of support,
|
||||
* specifically for creating LOB references.
|
||||
*
|
||||
* @return An appropriate {@link JdbcSupport} instance.
|
||||
*/
|
||||
public static JdbcSupport loadJdbcSupport(Connection jdbcConnection) {
|
||||
return new JdbcSupportImpl( useContextualLobCreation( jdbcConnection ) );
|
||||
}
|
||||
|
||||
private static final Class[] NO_ARG_SIG = new Class[0];
|
||||
private static final Object[] NO_ARGS = new Object[0];
|
||||
|
||||
/**
|
||||
* Basically here we are simply checking whether we can call the {@link Connection} methods for
|
||||
* LOB creation added in JDBC 4. We not only check whether the {@link Connection} declares these methods,
|
||||
* but also whether the actual {@link Connection} instance implements them (i.e. can be called without simply
|
||||
* throwing an exception).
|
||||
*
|
||||
* @param jdbcConnection The connection which can be used in level-of-support testing.
|
||||
*
|
||||
* @return True if the connection can be used to create LOBs; false otherwise.
|
||||
*/
|
||||
private static boolean useContextualLobCreation(Connection jdbcConnection) {
|
||||
if ( jdbcConnection == null ) {
|
||||
log.info( "Disabling contextual LOB creation as connection was null" );
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
try {
|
||||
DatabaseMetaData meta = jdbcConnection.getMetaData();
|
||||
// if the jdbc driver version is less than 4, it shouldn't have createClob
|
||||
if ( meta.getJDBCMajorVersion() < 4 ) {
|
||||
log.info(
|
||||
"Disabling contextual LOB creation as JDBC driver reported JDBC version [" +
|
||||
meta.getJDBCMajorVersion() + "] less than 4"
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch ( SQLException ignore ) {
|
||||
// ignore exception and continue
|
||||
}
|
||||
|
||||
Class connectionClass = Connection.class;
|
||||
Method createClobMethod = connectionClass.getMethod( "createClob", NO_ARG_SIG );
|
||||
if ( createClobMethod.getDeclaringClass().equals( Connection.class ) ) {
|
||||
// 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
|
||||
// check against createClob() as indicative of all; should we check against all 3 explicitly?
|
||||
try {
|
||||
Object clob = createClobMethod.invoke( jdbcConnection, NO_ARGS );
|
||||
try {
|
||||
Method freeMethod = clob.getClass().getMethod( "free", NO_ARG_SIG );
|
||||
freeMethod.invoke( clob, NO_ARGS );
|
||||
}
|
||||
catch ( Throwable ignore ) {
|
||||
log.trace( "Unable to free CLOB created to test createClob() implementation : " + ignore );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch ( Throwable t ) {
|
||||
log.info( "Disabling contextual LOB creation as createClob() method threw error : " + t );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( NoSuchMethodException ignore ) {
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -27,8 +27,7 @@ import java.sql.Connection;
|
|||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Provides callback access into the context in which the LOB is to be created. Mainly this is useful
|
||||
* for gaining access to the JDBC {@link Connection} for use in JDBC 4 environments.
|
||||
* Provides callback access into the context in which the LOB is to be created.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -36,7 +35,7 @@ public interface LobCreationContext {
|
|||
/**
|
||||
* The callback contract for making use of the JDBC {@link Connection}.
|
||||
*/
|
||||
public static interface Callback {
|
||||
public static interface Callback<T> {
|
||||
/**
|
||||
* Perform whatever actions are necessary using the provided JDBC {@link Connection}.
|
||||
*
|
||||
|
@ -44,7 +43,7 @@ public interface LobCreationContext {
|
|||
* @return The created LOB.
|
||||
* @throws SQLException
|
||||
*/
|
||||
public Object executeOnConnection(Connection connection) throws SQLException;
|
||||
public T executeOnConnection(Connection connection) throws SQLException;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,5 +52,5 @@ public interface LobCreationContext {
|
|||
* @param callback The callback to execute .
|
||||
* @return The LOB created by the callback.
|
||||
*/
|
||||
public Object execute(Callback callback);
|
||||
public <T> T execute(Callback<T> callback);
|
||||
}
|
||||
|
|
|
@ -27,10 +27,13 @@ import java.sql.Blob;
|
|||
import java.sql.Clob;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.sql.NClob;
|
||||
|
||||
/**
|
||||
* Contract for creating various LOB references.
|
||||
*
|
||||
* @todo LobCreator really needs to be an api since we expose it to users.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
* @author Gail Badner
|
||||
*/
|
||||
|
@ -92,7 +95,7 @@ public interface LobCreator {
|
|||
* @return The created NCLOB, castable as {@link Clob} as well as {@link NClobImplementer}. In JDK 1.6
|
||||
* environments, also castable to java.sql.NClob
|
||||
*/
|
||||
public Clob createNClob(String string);
|
||||
public NClob createNClob(String string);
|
||||
|
||||
/**
|
||||
* Create a NCLOB reference encapsulating the given character data.
|
||||
|
@ -102,5 +105,5 @@ public interface LobCreator {
|
|||
* @return The created NCLOB, castable as {@link Clob} as well as {@link NClobImplementer}. In JDK 1.6
|
||||
* environments, also castable to java.sql.NClob
|
||||
*/
|
||||
public Clob createNClob(Reader reader, long length);
|
||||
public NClob createNClob(Reader reader, long length);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ package org.hibernate.engine.jdbc;
|
|||
import java.sql.Clob;
|
||||
import java.io.Reader;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.sql.NClob;
|
||||
|
||||
/**
|
||||
* Manages aspects of proxying java.sql.NClobs for non-contextual creation, including proxy creation and
|
||||
|
@ -37,18 +38,7 @@ import java.lang.reflect.Proxy;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class NClobProxy extends ClobProxy {
|
||||
public static final Class[] PROXY_INTERFACES = new Class[] { determineNClobInterface(), NClobImplementer.class };
|
||||
|
||||
private static Class determineNClobInterface() {
|
||||
// java.sql.NClob is a simple marker interface extending java.sql.Clob. So if java.sql.NClob is not available
|
||||
// on the classloader, just use java.sql.Clob
|
||||
try {
|
||||
return getProxyClassLoader().loadClass( "java.sql.NClob" );
|
||||
}
|
||||
catch ( ClassNotFoundException e ) {
|
||||
return Clob.class;
|
||||
}
|
||||
}
|
||||
public static final Class[] PROXY_INTERFACES = new Class[] { NClob.class, NClobImplementer.class };
|
||||
|
||||
protected NClobProxy(String string) {
|
||||
super( string );
|
||||
|
@ -65,8 +55,8 @@ public class NClobProxy extends ClobProxy {
|
|||
*
|
||||
* @return The generated proxy.
|
||||
*/
|
||||
public static Clob generateProxy(String string) {
|
||||
return ( Clob ) Proxy.newProxyInstance(
|
||||
public static NClob generateProxy(String string) {
|
||||
return ( NClob ) Proxy.newProxyInstance(
|
||||
getProxyClassLoader(),
|
||||
PROXY_INTERFACES,
|
||||
new ClobProxy( string )
|
||||
|
@ -81,8 +71,8 @@ public class NClobProxy extends ClobProxy {
|
|||
*
|
||||
* @return The generated proxy.
|
||||
*/
|
||||
public static Clob generateProxy(Reader reader, long length) {
|
||||
return ( Clob ) Proxy.newProxyInstance(
|
||||
public static NClob generateProxy(Reader reader, long length) {
|
||||
return ( NClob ) Proxy.newProxyInstance(
|
||||
getProxyClassLoader(),
|
||||
PROXY_INTERFACES,
|
||||
new ClobProxy( reader, length )
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
|
||||
* third-party contributors as indicated by either @author tags or express
|
||||
* copyright attribution statements applied by the authors. All
|
||||
* third-party contributions are distributed under license by Red Hat Inc.
|
||||
* Copyright (c) 2010, 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 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
|
||||
|
@ -27,6 +27,7 @@ import java.sql.Blob;
|
|||
import java.sql.Clob;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.sql.NClob;
|
||||
|
||||
/**
|
||||
* {@link LobCreator} implementation using non-contextual or local creation, meaning that we generate the LOB
|
||||
|
@ -72,14 +73,14 @@ public class NonContextualLobCreator extends AbstractLobCreator implements LobCr
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Clob createNClob(String string) {
|
||||
public NClob createNClob(String string) {
|
||||
return NClobProxy.generateProxy( string );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Clob createNClob(Reader reader, long length) {
|
||||
public NClob createNClob(Reader reader, long length) {
|
||||
return NClobProxy.generateProxy( reader, length );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.engine.jdbc.jdbc4;
|
||||
package org.hibernate.jdbc;
|
||||
|
||||
import java.sql.*;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
|
@ -34,9 +34,9 @@ import java.io.Writer;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.hibernate.engine.jdbc.JdbcSupport;
|
||||
import org.hibernate.engine.jdbc.LobCreationContext;
|
||||
import org.hibernate.engine.jdbc.LobCreator;
|
||||
import org.hibernate.engine.jdbc.JdbcSupportLoader;
|
||||
import org.hibernate.engine.jdbc.ContextualLobCreator;
|
||||
import org.hibernate.engine.jdbc.BlobImplementer;
|
||||
import org.hibernate.engine.jdbc.ClobImplementer;
|
||||
|
@ -51,6 +51,8 @@ import org.hibernate.engine.jdbc.WrappedClob;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class JdbcSupportTest extends TestCase {
|
||||
private static JdbcSupport jdbcSupport = new JdbcSupport();
|
||||
|
||||
public void testConnectedLobCreator() throws SQLException {
|
||||
final Connection connection = createConnectionProxy(
|
||||
4,
|
||||
|
@ -79,7 +81,7 @@ public class JdbcSupportTest extends TestCase {
|
|||
}
|
||||
};
|
||||
|
||||
LobCreator lobCreator = JdbcSupportLoader.loadJdbcSupport( connection ).getLobCreator( lobCreationContext );
|
||||
LobCreator lobCreator = jdbcSupport.getLobCreator( lobCreationContext );
|
||||
assertTrue( lobCreator instanceof ContextualLobCreator );
|
||||
|
||||
Blob blob = lobCreator.createBlob( new byte[] {} );
|
||||
|
@ -103,61 +105,8 @@ public class JdbcSupportTest extends TestCase {
|
|||
connection.close();
|
||||
}
|
||||
|
||||
public void testConnectedLobCreatorWithUnSupportedCreations() throws SQLException {
|
||||
final Connection connection = createConnectionProxy(
|
||||
3,
|
||||
new JdbcLobBuilder() {
|
||||
public Blob createBlob() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Clob createClob() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public NClob createNClob() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
);
|
||||
final LobCreationContext lobCreationContext = new LobCreationContext() {
|
||||
public Object execute(Callback callback) {
|
||||
try {
|
||||
return callback.executeOnConnection( connection );
|
||||
}
|
||||
catch ( SQLException e ) {
|
||||
throw new RuntimeException( "Unexpected SQLException", e );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
LobCreator lobCreator = JdbcSupportLoader.loadJdbcSupport( connection ).getLobCreator( lobCreationContext );
|
||||
assertTrue( lobCreator instanceof NonContextualLobCreator );
|
||||
|
||||
Blob blob = lobCreator.createBlob( new byte[] {} );
|
||||
assertTrue( blob instanceof BlobImplementer );
|
||||
blob = lobCreator.wrap( blob );
|
||||
assertTrue( blob instanceof WrappedBlob );
|
||||
|
||||
Clob clob = lobCreator.createClob( "Hi" );
|
||||
assertTrue( clob instanceof ClobImplementer );
|
||||
clob = lobCreator.wrap( clob );
|
||||
assertTrue( clob instanceof WrappedClob );
|
||||
|
||||
Clob nclob = lobCreator.createNClob( "Hi" );
|
||||
assertTrue( nclob instanceof ClobImplementer );
|
||||
assertTrue( nclob instanceof NClobImplementer );
|
||||
nclob = lobCreator.wrap( nclob );
|
||||
assertTrue( nclob instanceof WrappedClob );
|
||||
|
||||
blob.free();
|
||||
clob.free();
|
||||
nclob.free();
|
||||
connection.close();
|
||||
}
|
||||
|
||||
public void testLegacyLobCreator() throws SQLException {
|
||||
LobCreator lobCreator = JdbcSupportLoader.loadJdbcSupport( null ).getLobCreator();
|
||||
LobCreator lobCreator = jdbcSupport.getLobCreator();
|
||||
|
||||
Blob blob = lobCreator.createBlob( new byte[] {} );
|
||||
assertTrue( blob instanceof BlobImplementer );
|
|
@ -12,7 +12,6 @@
|
|||
destdir="${target.dir}"
|
||||
failonerror="false"
|
||||
fork="true"
|
||||
executable="${jdk16_home}/bin/javac"
|
||||
target="1.5"
|
||||
classpath="${classpath}">
|
||||
<compilerarg value="-proc:only"/>
|
||||
|
|
|
@ -122,7 +122,6 @@
|
|||
<tasks>
|
||||
<property name="target.dir" value="${project.build.directory}/generated-src/jpamodelgen"/>
|
||||
<property name="src.dir" value="${project.build.testSourceDirectory}"/>
|
||||
<property name="jdk16_home" value="${jdk16_home}"/>
|
||||
<property name="classpath" refid="maven.test.classpath"/>
|
||||
<ant antfile="${basedir}/build.xml">
|
||||
<target name="generate-metamodel"/>
|
||||
|
@ -143,14 +142,6 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
|
|
|
@ -19,15 +19,6 @@
|
|||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
|
||||
~ third-party contributors as indicated by either @author tags or express
|
||||
~ copyright attribution statements applied by the authors. All
|
||||
~ third-party contributions are 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
|
||||
~ 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
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-parent</artifactId>
|
||||
<version>3.6.0-SNAPSHOT</version>
|
||||
<relativePath>../parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>hibernate-jdbc3-testing</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Hibernate JDBC3-JdbcSupport Testing</name>
|
||||
<description>Test support of JDBC3 through JdbcSupport</description>
|
||||
|
||||
<properties>
|
||||
<!-- Skip artifact deployment -->
|
||||
<maven.deploy.skip>true</maven.deploy.skip>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
|
||||
* third-party contributors as indicated by either @author tags or express
|
||||
* copyright attribution statements applied by the authors. All
|
||||
* third-party contributions are 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
|
||||
* 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.engine.jdbc.jdbc3;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Blob;
|
||||
import java.sql.Clob;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.hibernate.engine.jdbc.LobCreationContext;
|
||||
import org.hibernate.engine.jdbc.LobCreator;
|
||||
import org.hibernate.engine.jdbc.JdbcSupportLoader;
|
||||
import org.hibernate.engine.jdbc.BlobImplementer;
|
||||
import org.hibernate.engine.jdbc.WrappedBlob;
|
||||
import org.hibernate.engine.jdbc.WrappedClob;
|
||||
import org.hibernate.engine.jdbc.ClobImplementer;
|
||||
import org.hibernate.engine.jdbc.NClobImplementer;
|
||||
|
||||
|
||||
/**
|
||||
* TODO : javadoc
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class JdbcSupportTest extends TestCase {
|
||||
private static class LobCreationContextImpl implements LobCreationContext {
|
||||
public Object execute(Callback callback) {
|
||||
fail( "Unexpected call to getConnection" );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private LobCreationContextImpl lobCreationContext = new LobCreationContextImpl();
|
||||
|
||||
public void testLobCreator() throws ClassNotFoundException, SQLException {
|
||||
LobCreator lobCreator = JdbcSupportLoader.loadJdbcSupport( null ).getLobCreator( lobCreationContext );
|
||||
|
||||
Blob blob = lobCreator.createBlob( new byte[] {} );
|
||||
assertTrue( blob instanceof BlobImplementer );
|
||||
blob = lobCreator.wrap( blob );
|
||||
assertTrue( blob instanceof WrappedBlob );
|
||||
|
||||
Clob clob = lobCreator.createClob( "Hi" );
|
||||
assertTrue( clob instanceof ClobImplementer );
|
||||
clob = lobCreator.wrap( clob );
|
||||
assertTrue( clob instanceof WrappedClob );
|
||||
|
||||
Clob nclob = lobCreator.createNClob( "Hi" );
|
||||
assertTrue( nclob instanceof NClobImplementer );
|
||||
nclob = lobCreator.wrap( nclob );
|
||||
assertTrue( nclob instanceof WrappedClob );
|
||||
}
|
||||
|
||||
public void testLobAccess() throws SQLException {
|
||||
LobCreator lobCreator = JdbcSupportLoader.loadJdbcSupport( null ).getLobCreator( lobCreationContext );
|
||||
|
||||
Blob blob = lobCreator.createBlob( "Hi".getBytes() );
|
||||
assertEquals( 2, blob.length() );
|
||||
assertEquals( 2, blob.getBytes( 1, 5 ).length );
|
||||
blob.getBinaryStream();
|
||||
|
||||
Clob clob = lobCreator.createClob( "Hi" );
|
||||
assertEquals( 2, clob.length() );
|
||||
assertEquals( 2, clob.getSubString( 1, 5 ).length() );
|
||||
clob.getCharacterStream();
|
||||
clob.getAsciiStream();
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
#
|
||||
# Hibernate, Relational Persistence for Idiomatic Java
|
||||
#
|
||||
# Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
|
||||
# third-party contributors as indicated by either @author tags or express
|
||||
# copyright attribution statements applied by the authors. All
|
||||
# third-party contributions are 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
|
||||
# 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
|
||||
#
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target=System.out
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
|
||||
|
||||
|
||||
log4j.rootLogger=info, stdout
|
|
@ -1,76 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
|
||||
~ third-party contributors as indicated by either @author tags or express
|
||||
~ copyright attribution statements applied by the authors. All
|
||||
~ third-party contributions are 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
|
||||
~ 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
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-parent</artifactId>
|
||||
<version>3.6.0-SNAPSHOT</version>
|
||||
<relativePath>../parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>hibernate-jdbc4-testing</artifactId>
|
||||
<name>Hibernate JDBC4-JdbcSupport Testing</name>
|
||||
<description>Test support of JDBC4 through JdbcSupport</description>
|
||||
|
||||
<properties>
|
||||
<!-- Skip artifact deployment -->
|
||||
<maven.deploy.skip>true</maven.deploy.skip>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<compilerVersion>1.6</compilerVersion>
|
||||
<executable>${jdk16_home}/bin/javac</executable>
|
||||
<fork>true</fork>
|
||||
<verbose>true</verbose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<jvm>${jdk16_home}/bin/java</jvm>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,7 +0,0 @@
|
|||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target=System.out
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
|
||||
|
||||
|
||||
log4j.rootLogger=info, stdout
|
|
@ -116,28 +116,6 @@
|
|||
<groupId>org.jboss.maven.plugins</groupId>
|
||||
<artifactId>maven-jdocbook-style-plugin</artifactId>
|
||||
<extensions>true</extensions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.groovy.maven</groupId>
|
||||
<artifactId>gmaven-plugin</artifactId>
|
||||
<version>1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<source><![CDATA[
|
||||
def javaVersion=System.getProperty("java.version")
|
||||
if(!javaVersion.startsWith("1.5")){
|
||||
fail("Please using JDK5 to do Hibernate release!")
|
||||
}
|
||||
]]>
|
||||
</source>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
@ -153,8 +131,8 @@
|
|||
<configuration>
|
||||
<rules>
|
||||
<requireJavaVersion>
|
||||
<!-- require JDK 1.5 to run the build -->
|
||||
<version>[1.5,)</version>
|
||||
<!-- require JDK 1.6 to run the build -->
|
||||
<version>[1.6,)</version>
|
||||
</requireJavaVersion>
|
||||
<requireMavenVersion>
|
||||
<!-- we need at least Maven 2.0.8 because of a bug fix affecting our antlr usage -->
|
||||
|
@ -164,13 +142,12 @@
|
|||
</rules>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- by default, compile to JDK 1.5 compatibility (individual modules and/or user can override) -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- add specification/implementation details to the manifests -->
|
||||
|
|
17
pom.xml
17
pom.xml
|
@ -27,14 +27,14 @@
|
|||
<module>core</module>
|
||||
<module>testing</module>
|
||||
<module>testsuite</module>
|
||||
<module>entitymanager</module>
|
||||
<module>envers</module>
|
||||
<module>cache-ehcache</module>
|
||||
<module>cache-jbosscache</module>
|
||||
<module>cache-oscache</module>
|
||||
<module>cache-swarmcache</module>
|
||||
<module>connection-c3p0</module>
|
||||
<module>connection-proxool</module>
|
||||
<module>envers</module>
|
||||
<module>jdbc3-testing</module>
|
||||
<module>cache-infinispan</module>
|
||||
<!--
|
||||
Need to scope bytecode providers first...
|
||||
|
@ -72,19 +72,6 @@
|
|||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>jdk6-modules</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>disableJDK6Modules</name>
|
||||
<value>!true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>entitymanager</module>
|
||||
<module>jdbc4-testing</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>docs</id>
|
||||
<activation>
|
||||
|
|
|
@ -42,15 +42,5 @@
|
|||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -85,14 +85,6 @@
|
|||
</testResources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jboss.maven.plugins</groupId>
|
||||
<artifactId>maven-test-ext-plugin</artifactId>
|
||||
|
@ -120,27 +112,4 @@
|
|||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>jaxb</id>
|
||||
<activation>
|
||||
<jdk>1.5</jdk>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>2.1.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue