HHH-8960 Re-introducing a Properties instance variable and apply it when the session factory is built. This allows for Configuration#getProperties to return writable properties

Re-enabling tests which were based on the change in Configuration
This commit is contained in:
Hardy Ferentschik 2014-02-12 20:05:00 +01:00
parent d9a4e094a4
commit 77b497be98
5 changed files with 8 additions and 15 deletions

View File

@ -26,7 +26,6 @@ package org.hibernate.cfg;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.InputStream; import java.io.InputStream;
import java.io.Serializable;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -127,6 +126,7 @@ public class Configuration {
private Interceptor interceptor; private Interceptor interceptor;
private SessionFactoryObserver sessionFactoryObserver; private SessionFactoryObserver sessionFactoryObserver;
private CurrentTenantIdentifierResolver currentTenantIdentifierResolver; private CurrentTenantIdentifierResolver currentTenantIdentifierResolver;
private Properties properties;
public Configuration() { public Configuration() {
this( new BootstrapServiceRegistryBuilder().build() ); this( new BootstrapServiceRegistryBuilder().build() );
@ -174,6 +174,8 @@ public class Configuration {
entityTuplizerFactory = new EntityTuplizerFactory(); entityTuplizerFactory = new EntityTuplizerFactory();
//componentTuplizerFactory = new ComponentTuplizerFactory(); //componentTuplizerFactory = new ComponentTuplizerFactory();
interceptor = EmptyInterceptor.INSTANCE; interceptor = EmptyInterceptor.INSTANCE;
properties = new Properties( );
properties.putAll( standardServiceRegistryBuilder.getSettings());
} }
@ -185,8 +187,6 @@ public class Configuration {
* @return all properties * @return all properties
*/ */
public Properties getProperties() { public Properties getProperties() {
Properties properties = new Properties();
properties.putAll( standardServiceRegistryBuilder.getSettings() );
return properties; return properties;
} }
@ -198,8 +198,7 @@ public class Configuration {
* @return this for method chaining * @return this for method chaining
*/ */
public Configuration setProperties(Properties properties) { public Configuration setProperties(Properties properties) {
standardServiceRegistryBuilder.getSettings().clear(); this.properties = properties;
standardServiceRegistryBuilder.applySettings( properties );
return this; return this;
} }
@ -211,7 +210,7 @@ public class Configuration {
* @return The value currently associated with that property name; may be null. * @return The value currently associated with that property name; may be null.
*/ */
public String getProperty(String propertyName) { public String getProperty(String propertyName) {
Object o = standardServiceRegistryBuilder.getSettings().get( propertyName ); Object o = properties.get( propertyName );
return o instanceof String ? (String) o : null; return o instanceof String ? (String) o : null;
} }
@ -224,7 +223,7 @@ public class Configuration {
* @return this for method chaining * @return this for method chaining
*/ */
public Configuration setProperty(String propertyName, String value) { public Configuration setProperty(String propertyName, String value) {
standardServiceRegistryBuilder.applySetting( propertyName, value ); properties.setProperty( propertyName, value );
return this; return this;
} }
@ -236,7 +235,7 @@ public class Configuration {
* @return this for method chaining * @return this for method chaining
*/ */
public Configuration addProperties(Properties properties) { public Configuration addProperties(Properties properties) {
standardServiceRegistryBuilder.applySettings( properties ); this.properties.putAll( properties );
return this; return this;
} }
@ -695,6 +694,7 @@ public class Configuration {
*/ */
public SessionFactory buildSessionFactory() throws HibernateException { public SessionFactory buildSessionFactory() throws HibernateException {
log.debug( "Building session factory using internal StandardServiceRegistryBuilder" ); log.debug( "Building session factory using internal StandardServiceRegistryBuilder" );
standardServiceRegistryBuilder.applySettings( properties );
return buildSessionFactory( standardServiceRegistryBuilder.build() ); return buildSessionFactory( standardServiceRegistryBuilder.build() );
} }

View File

@ -218,7 +218,6 @@ public class AggressiveReleaseTest extends ConnectionManagementTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testConnectionMaintanenceDuringFlush() throws Throwable { public void testConnectionMaintanenceDuringFlush() throws Throwable {
// todo : no idea why this fails with metamodel // todo : no idea why this fails with metamodel

View File

@ -57,7 +57,6 @@ public class CustomDirtinessStrategyTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testOnlyCustomStrategy() { public void testOnlyCustomStrategy() {
// todo : not sure why this only fails with metamodel // todo : not sure why this only fails with metamodel
@ -91,7 +90,6 @@ public class CustomDirtinessStrategyTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testOnlyCustomStrategyConsultedOnNonDirty() throws Exception { public void testOnlyCustomStrategyConsultedOnNonDirty() throws Exception {
// todo : not sure why this only fails with metamodel // todo : not sure why this only fails with metamodel

View File

@ -80,7 +80,6 @@ public class CMTTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testConcurrent() throws Exception { public void testConcurrent() throws Exception {
sessionFactory().getStatistics().clear(); sessionFactory().getStatistics().clear();
assertEquals( 0, sessionFactory().getStatistics().getUpdateTimestampsCacheHitCount() ); assertEquals( 0, sessionFactory().getStatistics().getUpdateTimestampsCacheHitCount() );

View File

@ -35,12 +35,9 @@ import org.hibernate.jpa.AvailableSettings;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
@FailureExpectedWithNewMetamodel
public class XmlTest extends BaseEntityManagerFunctionalTestCase { public class XmlTest extends BaseEntityManagerFunctionalTestCase {
// failures from org.hibernate.tuple.PropertyFactory.buildEntityBasedAttribute again // failures from org.hibernate.tuple.PropertyFactory.buildEntityBasedAttribute again