HHH-5623 - Baseline on JDK 1.6

This commit is contained in:
Steve Ebersole 2010-10-08 15:36:02 -05:00
parent 7b521af146
commit a316a8a501
27 changed files with 427 additions and 443 deletions

View File

@ -547,6 +547,11 @@ public final class Environment {
*/ */
public static final String QUERY_PLAN_CACHE_MAX_SOFT_REFERENCES = "hibernate.query.plan_cache_max_soft_references"; public static final String QUERY_PLAN_CACHE_MAX_SOFT_REFERENCES = "hibernate.query.plan_cache_max_soft_references";
/**
* Should we not use contextual LOB creation (aka based on {@link java.sql.Connection#createBlob()} et al).
*/
public static final String NON_CONTEXTUAL_LOB_CREATION = "hibernate.jdbc.lob.non_contextual_creation";
private static final BytecodeProvider BYTECODE_PROVIDER_INSTANCE; private static final BytecodeProvider BYTECODE_PROVIDER_INSTANCE;
private static final boolean ENABLE_BINARY_STREAMS; private static final boolean ENABLE_BINARY_STREAMS;

View File

@ -155,13 +155,14 @@ public class SettingsFactory implements Serializable {
settings.setDataDefinitionImplicitCommit( metaReportsDDLCausesTxnCommit ); settings.setDataDefinitionImplicitCommit( metaReportsDDLCausesTxnCommit );
settings.setDataDefinitionInTransactionSupported( metaReportsDDLInTxnSupported ); settings.setDataDefinitionInTransactionSupported( metaReportsDDLInTxnSupported );
settings.setDialect( dialect ); settings.setDialect( dialect );
settings.setJdbcSupport( new JdbcSupport() );
//use dialect default properties //use dialect default properties
final Properties properties = new Properties(); final Properties properties = new Properties();
properties.putAll( dialect.getDefaultProperties() ); properties.putAll( dialect.getDefaultProperties() );
properties.putAll( props ); properties.putAll( props );
settings.setJdbcSupport( new JdbcSupport( ! PropertiesHelper.getBoolean( Environment.NON_CONTEXTUAL_LOB_CREATION, properties ) ) );
// Transaction settings: // Transaction settings:
TransactionFactory transactionFactory = createTransactionFactory(properties); TransactionFactory transactionFactory = createTransactionFactory(properties);

View File

@ -184,6 +184,7 @@ public class H2Dialect extends Dialect {
registerFunction( "user", new NoArgSQLFunction( "user", StandardBasicTypes.STRING ) ); registerFunction( "user", new NoArgSQLFunction( "user", StandardBasicTypes.STRING ) );
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE ); getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
getDefaultProperties().setProperty( Environment.NON_CONTEXTUAL_LOB_CREATION, "true" ); // http://code.google.com/p/h2database/issues/detail?id=235
} }
public String getAddColumnString() { public String getAddColumnString() {

View File

@ -31,14 +31,48 @@ import java.sql.ResultSet;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class JdbcSupport { public class JdbcSupport {
public final boolean userContextualLobCreator;
/**
* Create a support object
*
* @param userContextualLobCreator Should we use contextual (using the JDBC {@link java.sql.Connection}) to
* create LOB instances. In almost all instances this should be the case. However if the underlying driver
* does not support the {@link java.sql.Connection#createBlob()}, {@link java.sql.Connection#createClob()} or
* {@link java.sql.Connection#createNClob()} methods this will need to be set to false.
*/
public JdbcSupport(boolean userContextualLobCreator) {
this.userContextualLobCreator = userContextualLobCreator;
}
/**
* Get an explcitly non-contextual LOB creator.
*
* @return The LOB creator
*/
public LobCreator getLobCreator() { public LobCreator getLobCreator() {
return NonContextualLobCreator.INSTANCE; return NonContextualLobCreator.INSTANCE;
} }
/**
* Get a LOB creator, based on the given context
*
* @return The LOB creator
*/
public LobCreator getLobCreator(LobCreationContext lobCreationContext) { public LobCreator getLobCreator(LobCreationContext lobCreationContext) {
return new ContextualLobCreator( lobCreationContext ); return userContextualLobCreator
? new ContextualLobCreator( lobCreationContext )
: NonContextualLobCreator.INSTANCE;
} }
/**
* Wrap a result set in a "colun name cache" wrapper.
*
* @param resultSet The result set to wrap
* @param columnNameCache The column name cache.
*
* @return The wrapped result set.
*/
public ResultSet wrap(ResultSet resultSet, ColumnNameCache columnNameCache) { public ResultSet wrap(ResultSet resultSet, ColumnNameCache columnNameCache) {
return ResultSetWrapperProxy.generateProxy( resultSet, columnNameCache ); return ResultSetWrapperProxy.generateProxy( resultSet, columnNameCache );
} }

View File

@ -1,10 +1,10 @@
/* /*
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
* Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* third-party contributors as indicated by either @author tags or express * indicated by the @author tags or express copyright attribution
* copyright attribution statements applied by the authors. All * statements applied by the authors. All third-party contributions are
* third-party contributions are distributed under license by Red Hat Inc. * distributed under license by Red Hat Inc.
* *
* This copyrighted material is made available to anyone wishing to use, modify, * 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 * copy, or redistribute it subject to the terms and conditions of the GNU
@ -41,7 +41,6 @@ import org.hibernate.engine.jdbc.ContextualLobCreator;
import org.hibernate.engine.jdbc.BlobImplementer; import org.hibernate.engine.jdbc.BlobImplementer;
import org.hibernate.engine.jdbc.ClobImplementer; import org.hibernate.engine.jdbc.ClobImplementer;
import org.hibernate.engine.jdbc.NClobImplementer; import org.hibernate.engine.jdbc.NClobImplementer;
import org.hibernate.engine.jdbc.NonContextualLobCreator;
import org.hibernate.engine.jdbc.WrappedBlob; import org.hibernate.engine.jdbc.WrappedBlob;
import org.hibernate.engine.jdbc.WrappedClob; import org.hibernate.engine.jdbc.WrappedClob;
@ -51,7 +50,7 @@ import org.hibernate.engine.jdbc.WrappedClob;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class JdbcSupportTest extends TestCase { public class JdbcSupportTest extends TestCase {
private static JdbcSupport jdbcSupport = new JdbcSupport(); private static JdbcSupport jdbcSupport = new JdbcSupport( true );
public void testConnectedLobCreator() throws SQLException { public void testConnectedLobCreator() throws SQLException {
final Connection connection = createConnectionProxy( final Connection connection = createConnectionProxy(

View File

@ -10,6 +10,7 @@ import java.util.Map;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.ejb.test.TestCase; import org.hibernate.ejb.test.TestCase;
@ -28,7 +29,7 @@ public class BlobTest extends TestCase {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream( baos ); ObjectOutputStream oos = new ObjectOutputStream( baos );
oos.writeObject( image ); oos.writeObject( image );
reader.setImage( (Blob) Hibernate.createBlob( baos.toByteArray() ) ); reader.setImage( em.unwrap( Session.class ).getLobHelper().createBlob( baos.toByteArray() ) );
em.persist( reader ); em.persist( reader );
em.getTransaction().commit(); em.getTransaction().commit();
em.close(); //useless but y'a know em.close(); //useless but y'a know

View File

@ -11,11 +11,10 @@ import org.testng.Assert;
import java.util.Arrays; import java.util.Arrays;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
* @author Adam Warski (adam at warski dot org) * @author Adam Warski (adam at warski dot org)
*/ */
public abstract class AbstractAllAuditedTest extends AbstractEntityTest { public abstract class AbstractAllAuditedTest extends AbstractEntityTest {
private long ai_id; private long ai_id;
private long nai_id; private long nai_id;
@ -73,7 +72,7 @@ public abstract class AbstractAllAuditedTest extends AbstractEntityTest {
SimpleInterface si = getEntityManager().find(SimpleInterface.class, ai_id); SimpleInterface si = getEntityManager().find(SimpleInterface.class, ai_id);
assert si != null; assert si != null;
// levanto las de la revisión 1, ninguna debe ser null // levanto las de la revisi<EFBFBD>n 1, ninguna debe ser null
AuditedImplementor ai_rev1 = getAuditReader().find(AuditedImplementor.class, ai_id, 1); AuditedImplementor ai_rev1 = getAuditReader().find(AuditedImplementor.class, ai_id, 1);
assert ai_rev1 != null; assert ai_rev1 != null;
SimpleInterface si_rev1 = getAuditReader().find(SimpleInterface.class, ai_id, 1); SimpleInterface si_rev1 = getAuditReader().find(SimpleInterface.class, ai_id, 1);

View File

@ -3,21 +3,16 @@ package org.hibernate.envers.test.integration.interfaces.hbm.allAudited;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
* *
*/ */
@Audited @Audited
public class AuditedImplementor implements SimpleInterface { public class AuditedImplementor implements SimpleInterface {
private long id; private long id;
private String data; private String data;
private String auditedImplementorData; private String auditedImplementorData;
protected AuditedImplementor() { protected AuditedImplementor() {
} }
public long getId() { public long getId() {

View File

@ -2,20 +2,15 @@ package org.hibernate.envers.test.integration.interfaces.hbm.allAudited;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
* *
*/ */
public class NonAuditedImplementor implements SimpleInterface { public class NonAuditedImplementor implements SimpleInterface {
private long id; private long id;
private String data; private String data;
private String nonAuditedImplementorData; private String nonAuditedImplementorData;
protected NonAuditedImplementor() { protected NonAuditedImplementor() {
} }
public long getId() { public long getId() {

View File

@ -3,7 +3,7 @@ package org.hibernate.envers.test.integration.interfaces.hbm.allAudited;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
* *
*/ */
@Audited @Audited

View File

@ -9,8 +9,7 @@ import org.hibernate.envers.test.integration.interfaces.hbm.allAudited.AbstractA
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
*
*/ */
public class JoinedAllAuditedTest extends AbstractAllAuditedTest { public class JoinedAllAuditedTest extends AbstractAllAuditedTest {

View File

@ -9,8 +9,7 @@ import org.hibernate.envers.test.integration.interfaces.hbm.allAudited.AbstractA
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
*
*/ */
public class SubclassAllAuditedTest extends AbstractAllAuditedTest { public class SubclassAllAuditedTest extends AbstractAllAuditedTest {

View File

@ -9,8 +9,7 @@ import org.hibernate.envers.test.integration.interfaces.hbm.allAudited.AbstractA
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
*
*/ */
public class UnionAllAuditedTest extends AbstractAllAuditedTest { public class UnionAllAuditedTest extends AbstractAllAuditedTest {

View File

@ -8,12 +8,10 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
* *
*/ */
public abstract class AbstractPropertiesAuditedTest extends AbstractEntityTest { public abstract class AbstractPropertiesAuditedTest extends AbstractEntityTest {
private long ai_id; private long ai_id;
private long nai_id; private long nai_id;
@ -60,7 +58,7 @@ public abstract class AbstractPropertiesAuditedTest extends AbstractEntityTest {
ai_id); ai_id);
assert si != null; assert si != null;
// levanto las de la revisión 1, ninguna debe ser null // levanto las de la revisi<EFBFBD>n 1, ninguna debe ser null
AuditedImplementor ai_rev1 = getAuditReader().find( AuditedImplementor ai_rev1 = getAuditReader().find(
AuditedImplementor.class, ai_id, 1); AuditedImplementor.class, ai_id, 1);
assert ai_rev1 != null; assert ai_rev1 != null;
@ -71,10 +69,10 @@ public abstract class AbstractPropertiesAuditedTest extends AbstractEntityTest {
// data de las actuales no debe ser null // data de las actuales no debe ser null
assert ai.getData() != null; assert ai.getData() != null;
assert si.getData() != null; assert si.getData() != null;
// data de las revisiones No está auditada // data de las revisiones No est<EFBFBD> auditada
assert ai_rev1.getData() == null; assert ai_rev1.getData() == null;
assert si_rev1.getData() == null; assert si_rev1.getData() == null;
// numerito de las revisiones está auditada, debe ser igual a NUMERITO // numerito de las revisiones est<EFBFBD> auditada, debe ser igual a NUMERITO
assert ai_rev1.getNumerito() == NUMERITO; assert ai_rev1.getNumerito() == NUMERITO;
assert si_rev1.getNumerito() == NUMERITO; assert si_rev1.getNumerito() == NUMERITO;
} }

View File

@ -3,24 +3,17 @@ package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
* *
*/ */
@Audited @Audited
public class AuditedImplementor implements SimpleInterface { public class AuditedImplementor implements SimpleInterface {
private long id; private long id;
private String data; private String data;
private String auditedImplementorData; private String auditedImplementorData;
private int numerito; private int numerito;
protected AuditedImplementor() { protected AuditedImplementor() {
} }
public long getId() { public long getId() {

View File

@ -1,23 +1,15 @@
package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited; package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
*
*/ */
public class NonAuditedImplementor implements SimpleInterface { public class NonAuditedImplementor implements SimpleInterface {
private long id; private long id;
private String data; private String data;
private String nonAuditedImplementorData; private String nonAuditedImplementorData;
private int numerito; private int numerito;
protected NonAuditedImplementor() { protected NonAuditedImplementor() {
} }
public long getId() { public long getId() {

View File

@ -3,10 +3,9 @@ package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
* *
*/ */
public interface SimpleInterface { public interface SimpleInterface {
long getId(); long getId();

View File

@ -9,10 +9,9 @@ import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.Ab
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
* *
*/ */
public class JoinedPropertiesAuditedTest extends AbstractPropertiesAuditedTest { public class JoinedPropertiesAuditedTest extends AbstractPropertiesAuditedTest {
public void configure(Ejb3Configuration cfg) { public void configure(Ejb3Configuration cfg) {

View File

@ -9,10 +9,9 @@ import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.Ab
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
* *
*/ */
public class SubclassPropertiesAuditedTest extends AbstractPropertiesAuditedTest { public class SubclassPropertiesAuditedTest extends AbstractPropertiesAuditedTest {
public void configure(Ejb3Configuration cfg) { public void configure(Ejb3Configuration cfg) {
@ -24,7 +23,6 @@ public class SubclassPropertiesAuditedTest extends AbstractPropertiesAuditedTest
} }
} }
@Test @Test
public void testRetrieveAudited() { public void testRetrieveAudited() {
super.testRetrieveAudited(); super.testRetrieveAudited();

View File

@ -9,10 +9,9 @@ import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.Ab
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
* *
*/ */
public class UnionPropertiesAuditedTest extends AbstractPropertiesAuditedTest { public class UnionPropertiesAuditedTest extends AbstractPropertiesAuditedTest {
public void configure(Ejb3Configuration cfg) { public void configure(Ejb3Configuration cfg) {

View File

@ -8,12 +8,10 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
* *
*/ */
public abstract class AbstractPropertiesAudited2Test extends AbstractEntityTest { public abstract class AbstractPropertiesAudited2Test extends AbstractEntityTest {
private long ai_id; private long ai_id;
private long nai_id; private long nai_id;
@ -60,7 +58,7 @@ public abstract class AbstractPropertiesAudited2Test extends AbstractEntityTest
ai_id); ai_id);
assert si != null; assert si != null;
// levanto las de la revisión 1, ninguna debe ser null // levanto las de la revisi<EFBFBD>n 1, ninguna debe ser null
AuditedImplementor ai_rev1 = getAuditReader().find( AuditedImplementor ai_rev1 = getAuditReader().find(
AuditedImplementor.class, ai_id, 1); AuditedImplementor.class, ai_id, 1);
assert ai_rev1 != null; assert ai_rev1 != null;
@ -71,10 +69,10 @@ public abstract class AbstractPropertiesAudited2Test extends AbstractEntityTest
// data de las actuales no debe ser null // data de las actuales no debe ser null
assert ai.getData() != null; assert ai.getData() != null;
assert si.getData() != null; assert si.getData() != null;
// data de las revisiones está auditada // data de las revisiones est<EFBFBD> auditada
assert ai_rev1.getData() != null; assert ai_rev1.getData() != null;
assert si_rev1.getData() != null; assert si_rev1.getData() != null;
// numerito de las revisiones está auditada, debe ser igual a NUMERITO // numerito de las revisiones est<EFBFBD> auditada, debe ser igual a NUMERITO
assert ai_rev1.getNumerito() == NUMERITO; assert ai_rev1.getNumerito() == NUMERITO;
assert si_rev1.getNumerito() == NUMERITO; assert si_rev1.getNumerito() == NUMERITO;
} }

View File

@ -3,24 +3,17 @@ package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
* *
*/ */
@Audited @Audited
public class AuditedImplementor implements SimpleInterface { public class AuditedImplementor implements SimpleInterface {
private long id; private long id;
private String data; private String data;
private String auditedImplementorData; private String auditedImplementorData;
private int numerito; private int numerito;
protected AuditedImplementor() { protected AuditedImplementor() {
} }
public long getId() { public long getId() {

View File

@ -1,23 +1,16 @@
package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2; package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
* *
*/ */
public class NonAuditedImplementor implements SimpleInterface { public class NonAuditedImplementor implements SimpleInterface {
private long id; private long id;
private String data; private String data;
private String nonAuditedImplementorData; private String nonAuditedImplementorData;
private int numerito; private int numerito;
protected NonAuditedImplementor() { protected NonAuditedImplementor() {
} }
public long getId() { public long getId() {

View File

@ -3,10 +3,9 @@ package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
* *
*/ */
public interface SimpleInterface { public interface SimpleInterface {
long getId(); long getId();

View File

@ -9,10 +9,8 @@ import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.A
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
*
*/ */
public class JoinedPropertiesAudited2Test extends AbstractPropertiesAudited2Test { public class JoinedPropertiesAudited2Test extends AbstractPropertiesAudited2Test {
public void configure(Ejb3Configuration cfg) { public void configure(Ejb3Configuration cfg) {

View File

@ -9,10 +9,9 @@ import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.A
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
* *
*/ */
public class SubclassPropertiesAudited2Test extends AbstractPropertiesAudited2Test { public class SubclassPropertiesAudited2Test extends AbstractPropertiesAudited2Test {
public void configure(Ejb3Configuration cfg) { public void configure(Ejb3Configuration cfg) {

View File

@ -9,10 +9,9 @@ import org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.A
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* @author Hernán Chanfreau * @author Hern<EFBFBD>n Chanfreau
* *
*/ */
public class UnionPropertiesAudited2Test extends AbstractPropertiesAudited2Test { public class UnionPropertiesAudited2Test extends AbstractPropertiesAudited2Test {
public void configure(Ejb3Configuration cfg) { public void configure(Ejb3Configuration cfg) {