[jboss-cvs] JBossAS SVN: r104585 - in branches/JBPAPP_5_1: hibernate-int/src/main/org/jboss/hibernate/deployers/metadata and 9 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri May 7 18:24:52 EDT 2010


Author: bstansberry at jboss.com
Date: 2010-05-07 18:24:51 -0400 (Fri, 07 May 2010)
New Revision: 104585

Added:
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCache.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCacheProvider.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockInterceptor.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockListenerInjector.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegion.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegionFactory.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/SimpleJtaTransactionImpl.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/SimpleJtaTransactionManagerImpl.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/TransactionManagerLookupImpl.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/test/HarWithStandardPropertiesUnitTestCase.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/test/HibernateConfigurationUnitTestCase.java
   branches/JBPAPP_5_1/testsuite/src/resources/hibernate/jbas7411/
   branches/JBPAPP_5_1/testsuite/src/resources/hibernate/jbas7411/Timers.hbm.xml
   branches/JBPAPP_5_1/testsuite/src/resources/hibernate/jbas7411/jboss-hibernate.xml
Removed:
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCache.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCacheProvider.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockInterceptor.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockListenerInjector.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegion.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegionFactory.java
   branches/JBPAPP_5_1/testsuite/src/resources/hibernate/jbas7411/Timers.hbm.xml
   branches/JBPAPP_5_1/testsuite/src/resources/hibernate/jbas7411/jboss-hibernate.xml
Modified:
   branches/JBPAPP_5_1/hibernate-int/.classpath
   branches/JBPAPP_5_1/hibernate-int/src/main/org/jboss/hibernate/deployers/metadata/SessionFactoryMetaData.java
   branches/JBPAPP_5_1/hibernate-int/src/main/org/jboss/hibernate/jmx/Hibernate.java
   branches/JBPAPP_5_1/testsuite/.classpath
   branches/JBPAPP_5_1/testsuite/imports/sections/hibernate.xml
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/CacheManagerUnitTestCase.java
Log:
[JBPAPP-4244] Make Hibernate deployer flexible re: hibernate config properties 

Modified: branches/JBPAPP_5_1/hibernate-int/.classpath
===================================================================
--- branches/JBPAPP_5_1/hibernate-int/.classpath	2010-05-07 21:32:05 UTC (rev 104584)
+++ branches/JBPAPP_5_1/hibernate-int/.classpath	2010-05-07 22:24:51 UTC (rev 104585)
@@ -5,7 +5,7 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="lib" path="/thirdparty/hibernate/lib/hibernate-core.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/hibernate/lib/hibernate-jmx.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/org/hibernate/lib/hibernate-jbosscache2.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/hibernate/lib/hibernate-jbosscache2.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/cache/jbosscache-core/lib/jbosscache-core.jar" sourcepath="/thirdparty/jboss/cache/jbosscache-core/lib/jbosscache-core-sources.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-reflect/lib/jboss-reflect.jar" sourcepath="/thirdparty/jboss/jboss-reflect/lib/jboss-reflect-sources.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-kernel.jar" sourcepath="/thirdparty/jboss/microcontainer/lib/jboss-kernel-sources.jar"/>

Modified: branches/JBPAPP_5_1/hibernate-int/src/main/org/jboss/hibernate/deployers/metadata/SessionFactoryMetaData.java
===================================================================
--- branches/JBPAPP_5_1/hibernate-int/src/main/org/jboss/hibernate/deployers/metadata/SessionFactoryMetaData.java	2010-05-07 21:32:05 UTC (rev 104584)
+++ branches/JBPAPP_5_1/hibernate-int/src/main/org/jboss/hibernate/deployers/metadata/SessionFactoryMetaData.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -81,8 +81,7 @@
       builder.addPropertyMetaData("sessionFactoryName", getName());
       if (properties != null && properties.isEmpty() == false)
       {
-         for (BaseNamedElement bne : properties)
-            builder.addPropertyMetaData(bne.getName(), bne.getValue());
+         builder.addPropertyMetaData("configurationElements", properties);
       }
       if (depends != null && depends.isEmpty() == false)
       {

Modified: branches/JBPAPP_5_1/hibernate-int/src/main/org/jboss/hibernate/jmx/Hibernate.java
===================================================================
--- branches/JBPAPP_5_1/hibernate-int/src/main/org/jboss/hibernate/jmx/Hibernate.java	2010-05-07 21:32:05 UTC (rev 104584)
+++ branches/JBPAPP_5_1/hibernate-int/src/main/org/jboss/hibernate/jmx/Hibernate.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -22,9 +22,15 @@
 package org.jboss.hibernate.jmx;
 
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.Collections;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
 
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
@@ -38,10 +44,13 @@
 import org.hibernate.jmx.StatisticsServiceMBean;
 import org.hibernate.transaction.JBossTransactionManagerLookup;
 import org.hibernate.transaction.JTATransactionFactory;
+import org.hibernate.Version;
+import org.jboss.aop.microcontainer.aspects.jmx.JMX;
 import org.jboss.beans.metadata.api.annotations.Inject;
 import org.jboss.beans.metadata.api.model.FromContext;
 import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
 import org.jboss.hibernate.ListenerInjector;
+import org.jboss.hibernate.deployers.metadata.BaseNamedElement;
 import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
 import org.jboss.kernel.spi.dependency.KernelController;
 import org.jboss.logging.Logger;
@@ -66,56 +75,78 @@
 
    public static final String SESSION_FACTORY_CREATE = "hibernate.sessionfactory.create";
    public static final String SESSION_FACTORY_DESTROY = "hibernate.sessionfactory.destroy";
+   
+   // Legacy mbean/MC bean configuration attributes "passed through" to Hibernate
+   private static final String DATASOURCE_NAME = "datasourceName";
+   private static final String DIALECT = "dialect";
+   private static final String DEFAULT_SCHEMA = "defaultSchema";
+   private static final String DEFAULT_CATALOG = "defaultCatalog";
+   private static final String SQL_COMMENTS_ENABLED = "sqlCommentsEnabled";
+   private static final String  MAX_FETCH_DEPTH = "maxFetchDepth";
+   private static final String JDBC_FETCH_SIZE = "jdbcFetchSize";
+   private static final String JDBC_BATCH_SIZE = "jdbcBatchSize";
+   private static final String BATCH_VERSIONED_DATA_ENABLED = "batchVersionedDataEnabled";
+   private static final String JDBC_SCROLLABLE_RESULT_SET_ENABLED = "jdbcScrollableResultSetEnabled";
+   private static final String GET_GENERATED_KEYS_ENABLED = "getGeneratedKeysEnabled";
+   private static final String STREAMS_FOR_BINARY_ENABLED = "streamsForBinaryEnabled";
+   private static final String HBM2DDL_AUTO = "hbm2ddlAuto";
+   private static final String QUERY_SUBSTITUTIONS = "querySubstitutions";
+   private static final String SHOW_SQL_ENABLED = "showSqlEnabled";
+   private static final String USERNAME = "username";
+   private static final String PASSWORD = "password";
+   private static final String SECOND_LEVEL_CACHE_ENABLED = "secondLevelCacheEnabled";
+   private static final String QUERY_CACHE_ENABLED = "queryCacheEnabled";
+   private static final String CACHE_PROVIDER_CLASS = "cacheProviderClass";
+   private static final String CACHE_REGION_FACTORY_CLASS = "cacheRegionFactoryClass";
+   private static final String DEPLOYED_CACHE_JNDI_NAME = "deployedCacheJndiName";
+   private static final String DEPLOYED_CACHE_MANAGER_JNDI_NAME = "deployedCacheManagerJndiName";
+   private static final String MINIMAL_PUTS_ENABLED = "minimalPutsEnabled";
+   private static final String CACHE_REGION_PREFIX = "cacheRegionPrefix";
+   private static final String STRUCTURED_CACHE_ENTRIES_ENABLED = "useStructuredCacheEntriesEnabled";
+   private static final String STAT_GENERATION_ENABLED = "statGenerationEnabled";
+   private static final String REFLECTION_OPTIMIZATION_ENABLED = "reflectionOptimizationEnabled";
 
-   // Configuration attributes "passed through" to Hibernate
-   private String datasourceName;
-   private String dialect;
-   private String defaultSchema;
-   private String defaultCatalog;
-   private Boolean sqlCommentsEnabled;
-   private Integer maxFetchDepth;
-   private Integer jdbcFetchSize;
-   private Integer jdbcBatchSize;
-   private Boolean batchVersionedDataEnabled;
-   private Boolean jdbcScrollableResultSetEnabled;
-   private Boolean getGeneratedKeysEnabled;
-   private Boolean streamsForBinaryEnabled;
-   private String hbm2ddlAuto;
-   private String querySubstitutions;
-   private Boolean showSqlEnabled;
-   private String username;
-   private String password;
-   private Boolean secondLevelCacheEnabled = Boolean.TRUE;
-   private Boolean queryCacheEnabled;
-   private String cacheProviderClass;
-   private String cacheRegionFactoryClass;
-   private String deployedCacheJndiName;
-   private String deployedCacheManagerJndiName;
-   private Boolean minimalPutsEnabled;
-   private String cacheRegionPrefix;
-   private Boolean structuredCacheEntriesEnabled;
-   private Boolean statGenerationEnabled;
-   private Boolean reflectionOptimizationEnabled;
-
    // Configuration attributes used by the MBean
    private String sessionFactoryName;
+   private static final String SESSION_FACTORY_INTERCEPTOR = "sessionFactoryInterceptor";
    private String sessionFactoryInterceptor;
+   private static final String LISTENER_INJECTOR = "listenerInjector";
    private String listenerInjector;
+   private static final String HAR_URL = "harUrl";
    private URL harUrl;
+   private static final String SCAN_FOR_MAPPINGS_ENABLED = "scanForMappingsEnabled";
    private boolean scanForMappingsEnabled = false;
 
    // Internal state
+   
+   // Storage of injected configuration values
+   private final Map<String, Object> configurationElements = Collections.synchronizedMap(new HashMap<String, Object>());
+   // The actual properties stored in hibernate Configuration object when SessionFactory was built
+   private Properties sessionFactoryProperties;
    private VirtualFile root;
    private boolean dirty = false;
    private Date runningSince;
    private SessionFactory sessionFactory;
    private String hibernateStatisticsServiceName;
+   
+   // For unit testing
+   private boolean bindInJndi = true;
 
-   // back compatible
+   /**
+    * Backward compatible constructor. Usage requires configuring a 
+    * {@link #setHarUrl(URL) HAR URL} before calling {@link #start()}.
+    */
    public Hibernate()
    {
    }
-
+   
+   /**
+    * Create a new Hibernate instance.
+    * 
+    * @param root root file for the deployment. Cannot be <code>null</code>
+    * 
+    * @throws IllegalArgumentException if <code>root</code> is <code>null</code>
+    */
    public Hibernate(VirtualFile root)
    {
       if (root == null)
@@ -123,6 +154,22 @@
       this.root = root;
    }
 
+   /**
+    * For use in unit testing
+    * 
+    * @param root root of the deployment. May be <code>null</code>, in which
+    *             case configuring a {@link #setHarUrl(URL) HAR URL} before 
+    *             calling {@link #start()} is required
+    * @param bindInJndi <code>true</code> if the SessionFactory should be bound
+    *                   in JNDI (the default); <code>false</code> if not (to
+    *                   ease basic unit testing)
+    */
+   protected Hibernate(VirtualFile root, boolean bindInJndi)
+   {
+      this.root = root;
+      this.bindInJndi = bindInJndi;
+   }
+
    // Injected from underlying MC
    private Object beanName;
    private KernelController controller;
@@ -138,6 +185,78 @@
    {
       this.controller = controller;
    }
+   
+   public Properties getConfigurationProperties()
+   {
+      Properties props = new Properties();
+      if (sessionFactoryProperties == null)
+      {
+         for (Map.Entry<String, Object> coEntry : configurationElements.entrySet())
+         {
+            props.setProperty(coEntry.getKey(), coEntry.getValue().toString());
+         }
+      }
+      else
+      {
+         return new Properties(sessionFactoryProperties);
+      }
+      return props;
+   }
+   
+   public Set<BaseNamedElement> getConfigurationElements()
+   {
+      Set<BaseNamedElement> result = new HashSet<BaseNamedElement>();
+      for (Map.Entry<String, Object> entry : configurationElements.entrySet())
+      {
+         BaseNamedElement element = new BaseNamedElement();
+         element.setName(entry.getKey());
+         element.setValue(entry.getValue());
+         result.add(element);
+      }
+      return result;
+   }
+   
+   public void setConfigurationElements(Set<BaseNamedElement> elements)
+   {
+      if (elements != null)
+      {
+         for (BaseNamedElement element : elements)
+         {
+            // Handle special elements that don't get passed through to
+            // Hibernate Configuration object
+            String name = element.getName();
+            Object value = element.getValue();
+            if ( SESSION_FACTORY_INTERCEPTOR.equals(name) && value != null )
+            {
+               setSessionFactoryInterceptor(value.toString());
+            }
+            else if ( LISTENER_INJECTOR.equals(name) && value != null )
+            {
+               setListenerInjector(value.toString());
+            }
+            else if ( HAR_URL.equals(name) && value != null )
+            {
+               try
+               {
+                  setHarUrl(new URL(value.toString()));
+               }
+               catch (MalformedURLException e)
+               {
+                  throw new IllegalArgumentException("Value " + value + " for property " + name + " is not a valid URL", e);
+               }
+            }
+            else if ( SCAN_FOR_MAPPINGS_ENABLED.equals(name) && value != null )
+            {
+               setScanForMappingsEnabled(Boolean.valueOf(value.toString()));
+            }
+            else
+            {
+               // The 99% case -- pass through to Hibernate
+               configurationElements.put(element.getName(), element.getValue());
+            }
+         }
+      }
+   }
 
    /**
     * Configure Hibernate and bind the <tt>SessionFactory</tt> to JNDI.
@@ -195,13 +314,15 @@
          cfg.setInterceptor( interceptorInstance );
       }
 
+      sessionFactoryProperties = new Properties(cfg.getProperties());
+      
       // Generate sf....
       sessionFactory = cfg.buildSessionFactory();
 
       try
       {
          // Handle stat-mbean creation/registration....
-         if ( sessionFactory.getStatistics() != null && sessionFactory.getStatistics().isStatisticsEnabled() )
+         if ( controller != null && sessionFactory.getStatistics() != null && sessionFactory.getStatistics().isStatisticsEnabled() )
          {
             String serviceName = beanName.toString();
             if( serviceName.indexOf("type=service") != -1 )
@@ -217,11 +338,10 @@
             hibernateStatisticsService.setSessionFactory( sessionFactory );
             BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(hibernateStatisticsServiceName, StatisticsService.class.getName());
             StringBuffer buffer = new StringBuffer();
-            buffer.append("@org.jboss.aop.microcontainer.aspects.jmx.JMX(name=\"").append(hibernateStatisticsServiceName).append("JMX\"");
+            buffer.append("@").append(JMX.class.getName()).append("(name=\"").append(hibernateStatisticsServiceName).append("JMX\"");
             buffer.append(", exposedInterface=").append(StatisticsServiceMBean.class.getName()).append(".class, registerDirectly=true)");
             String jmxAnnotation = buffer.toString();
-            // todo - add the @JMX into annotations
-            //builder.addAnnotation(jmxAnnotation);
+            builder.addAnnotation(jmxAnnotation);
             controller.install(builder.getBeanMetaData(), hibernateStatisticsService);
          }
 
@@ -257,6 +377,7 @@
          sessionFactory.close();
          sessionFactory = null;
          runningSince = null;
+         sessionFactoryProperties = null;
 
          if ( hibernateStatisticsServiceName != null )
          {
@@ -283,6 +404,8 @@
          root = VFS.getRoot(harUrl);
       }
 
+      log.debug("Scanning for Hibernate mappings, root: " + root);
+
       HibernateMappingVisitor visitor = new HibernateMappingVisitor();
       root.visit(visitor);
       for (URL url : visitor.getUrls())
@@ -300,77 +423,101 @@
     */
    private void transferSettings(Properties settings)
    {
-      if ( cacheProviderClass == null )
+      // Establish defaults
+      if ( getCacheProviderClass() == null )
       {
-         cacheProviderClass = "org.hibernate.cache.HashtableCacheProvider";
+         setCacheProviderClass("org.hibernate.cache.HashtableCacheProvider");
       }
-
-      log.debug( "Using JDBC batch size : " + jdbcBatchSize );
-
-      setUnlessNull( settings, Environment.DATASOURCE, datasourceName );
-      setUnlessNull( settings, Environment.DIALECT, dialect );
-      setUnlessNull( settings, Environment.CACHE_PROVIDER, cacheProviderClass );
-      setUnlessNull( settings, Environment.CACHE_REGION_FACTORY, cacheRegionFactoryClass );
-      setUnlessNull( settings, Environment.CACHE_REGION_PREFIX, cacheRegionPrefix );
-      setUnlessNull( settings, Environment.USE_MINIMAL_PUTS, minimalPutsEnabled );
-      setUnlessNull( settings, Environment.HBM2DDL_AUTO, hbm2ddlAuto );
-      setUnlessNull( settings, Environment.DEFAULT_SCHEMA, defaultSchema );
-      setUnlessNull( settings, Environment.STATEMENT_BATCH_SIZE, jdbcBatchSize );
-      setUnlessNull( settings, Environment.USE_SQL_COMMENTS, sqlCommentsEnabled );
-
-      setUnlessNull( settings, Environment.STATEMENT_FETCH_SIZE, jdbcFetchSize );
-      setUnlessNull( settings, Environment.USE_SCROLLABLE_RESULTSET, jdbcScrollableResultSetEnabled );
-      setUnlessNull( settings, Environment.USE_QUERY_CACHE, queryCacheEnabled );
-      setUnlessNull( settings, Environment.USE_STRUCTURED_CACHE, structuredCacheEntriesEnabled );
-      setUnlessNull( settings, Environment.QUERY_SUBSTITUTIONS, querySubstitutions );
-      setUnlessNull( settings, Environment.MAX_FETCH_DEPTH, maxFetchDepth );
-      setUnlessNull( settings, Environment.SHOW_SQL, showSqlEnabled );
-      setUnlessNull( settings, Environment.USE_GET_GENERATED_KEYS, getGeneratedKeysEnabled );
-      setUnlessNull( settings, Environment.USER, username );
-      setUnlessNull( settings, Environment.PASS, password );
-      setUnlessNull( settings, Environment.BATCH_VERSIONED_DATA, batchVersionedDataEnabled );
-      setUnlessNull( settings, Environment.USE_STREAMS_FOR_BINARY, streamsForBinaryEnabled );
-      setUnlessNull( settings, Environment.USE_REFLECTION_OPTIMIZER, reflectionOptimizationEnabled );
-      setUnlessNull( settings, Environment.GENERATE_STATISTICS, statGenerationEnabled );
-
-      setUnlessNull(
-            settings, Environment.TRANSACTION_MANAGER_STRATEGY, JBossTransactionManagerLookup.class.getName()
-      );
-      setUnlessNull( settings, Environment.TRANSACTION_STRATEGY, JTATransactionFactory.class.getName() );
-
-      if (this.deployedCacheJndiName != null)
+      if ( getSecondLevelCacheEnabled() == null)
       {
-         settings.setProperty(org.hibernate.cache.jbc2.builder.JndiSharedCacheInstanceManager.CACHE_RESOURCE_PROP, this.deployedCacheJndiName);
-         
-         // Implies shared cache region factory
-         if (!settings.containsKey(Environment.CACHE_REGION_FACTORY))
-         {
-            settings.setProperty(Environment.CACHE_REGION_FACTORY, org.hibernate.cache.jbc2.JndiSharedJBossCacheRegionFactory.class.getName());
-         }
+         setSecondLevelCacheEnabled(Boolean.TRUE);
       }
+      if (configurationElements.get(Environment.TRANSACTION_MANAGER_STRATEGY) == null)
+      {
+         configurationElements.put(Environment.TRANSACTION_MANAGER_STRATEGY, JBossTransactionManagerLookup.class.getName());
+      }
+      if (configurationElements.get(Environment.TRANSACTION_STRATEGY) == null)
+      {
+         configurationElements.put(Environment.TRANSACTION_STRATEGY, JTATransactionFactory.class.getName());
+      }
       
-      if (this.deployedCacheManagerJndiName != null)
+      if ( getDeployedCacheJndiName() != null && getCacheRegionFactoryClass() == null)
       {
-         settings.setProperty(org.hibernate.cache.jbc2.builder.JndiMultiplexingCacheInstanceManager.CACHE_FACTORY_RESOURCE_PROP, this.deployedCacheManagerJndiName);
-         
+         // Implies shared cache region factory
+         configurationElements.put(Environment.CACHE_REGION_FACTORY, org.hibernate.cache.jbc2.JndiSharedJBossCacheRegionFactory.class.getName());
+      }
+
+      if ( getDeployedCacheManagerJndiName() != null && getCacheRegionFactoryClass() == null)
+      {
          // Implies multliplexed cache region factory
-         if (!settings.containsKey(Environment.CACHE_REGION_FACTORY))
-         {
-            settings.setProperty(Environment.CACHE_REGION_FACTORY, org.hibernate.cache.jbc2.JndiMultiplexedJBossCacheRegionFactory.class.getName());
-         }
+         configurationElements.put(Environment.CACHE_REGION_FACTORY, org.hibernate.cache.jbc2.JndiMultiplexedJBossCacheRegionFactory.class.getName());
       }
 
-      settings.setProperty( Environment.FLUSH_BEFORE_COMPLETION, "true" );
-      settings.setProperty( Environment.AUTO_CLOSE_SESSION, "true" );
-
+      if (configurationElements.get(Environment.FLUSH_BEFORE_COMPLETION) == null)
+      {
+         configurationElements.put( Environment.FLUSH_BEFORE_COMPLETION, "true" );
+      }
+      if (configurationElements.get(Environment.AUTO_CLOSE_SESSION) == null)
+      {
+         configurationElements.put( Environment.AUTO_CLOSE_SESSION, "true" );
+      }
+      
       // This is really H3-version-specific:
       // in 3.0.3 and later, this should be the ConnectionReleaseMode enum;
       // in 3.0.2, this is a true/false setting;
       // in 3.0 -> 3.0.1, there is no such setting
       //
       // so we just set them both :)
-      settings.setProperty( "hibernate.connection.agressive_release", "true" );
-      settings.setProperty( "hibernate.connection.release_mode", "after_statement" );
+      if (configurationElements.get("hibernate.connection.agressive_release") == null)
+      {
+         configurationElements.put( "hibernate.connection.agressive_release", "true" );
+      }
+      if (configurationElements.get("hibernate.connection.release_mode") == null)
+      {
+         configurationElements.put( "hibernate.connection.release_mode", "after_statement" );
+      }
+
+      log.debug( "Using JDBC batch size : " + getJdbcBatchSize() );
+      
+      // Translate any legacy "bean property name" elements
+      Map<String, Object> ourConfig = new HashMap<String, Object>(configurationElements);
+      
+      setUnlessNull( settings, Environment.DATASOURCE, ourConfig.remove(DATASOURCE_NAME) );
+      setUnlessNull( settings, Environment.DIALECT, ourConfig.remove(DIALECT) );
+      setUnlessNull( settings, Environment.CACHE_PROVIDER, ourConfig.remove(CACHE_PROVIDER_CLASS) );
+      setUnlessNull( settings, Environment.CACHE_REGION_FACTORY, ourConfig.remove(CACHE_REGION_FACTORY_CLASS) );
+      setUnlessNull( settings, Environment.CACHE_REGION_PREFIX, ourConfig.remove(CACHE_REGION_PREFIX) );
+      setUnlessNull( settings, Environment.USE_MINIMAL_PUTS, ourConfig.remove(MINIMAL_PUTS_ENABLED) );
+      setUnlessNull( settings, Environment.HBM2DDL_AUTO, ourConfig.remove(HBM2DDL_AUTO) );
+      setUnlessNull( settings, Environment.DEFAULT_SCHEMA, ourConfig.remove(DEFAULT_SCHEMA) );
+      setUnlessNull( settings, Environment.STATEMENT_BATCH_SIZE, ourConfig.remove(JDBC_BATCH_SIZE) );
+      setUnlessNull( settings, Environment.USE_SQL_COMMENTS, ourConfig.remove(SQL_COMMENTS_ENABLED) );
+
+      setUnlessNull( settings, Environment.STATEMENT_FETCH_SIZE, ourConfig.remove(JDBC_FETCH_SIZE) );
+      setUnlessNull( settings, Environment.USE_SCROLLABLE_RESULTSET, ourConfig.remove(JDBC_SCROLLABLE_RESULT_SET_ENABLED) );
+      setUnlessNull( settings, Environment.USE_QUERY_CACHE, ourConfig.remove(QUERY_CACHE_ENABLED) );
+      setUnlessNull( settings, Environment.USE_STRUCTURED_CACHE, ourConfig.remove(STRUCTURED_CACHE_ENTRIES_ENABLED) );
+      setUnlessNull( settings, Environment.QUERY_SUBSTITUTIONS, ourConfig.remove(QUERY_SUBSTITUTIONS) );
+      setUnlessNull( settings, Environment.MAX_FETCH_DEPTH, ourConfig.remove(MAX_FETCH_DEPTH) );
+      setUnlessNull( settings, Environment.SHOW_SQL, ourConfig.remove(SHOW_SQL_ENABLED) );
+      setUnlessNull( settings, Environment.USE_GET_GENERATED_KEYS, ourConfig.remove(GET_GENERATED_KEYS_ENABLED) );
+      setUnlessNull( settings, Environment.USER, ourConfig.remove(USERNAME) );
+      setUnlessNull( settings, Environment.PASS, ourConfig.remove(PASSWORD) );
+      setUnlessNull( settings, Environment.BATCH_VERSIONED_DATA, ourConfig.remove(BATCH_VERSIONED_DATA_ENABLED) );
+      setUnlessNull( settings, Environment.USE_STREAMS_FOR_BINARY, ourConfig.remove(STREAMS_FOR_BINARY_ENABLED) );
+      setUnlessNull( settings, Environment.USE_REFLECTION_OPTIMIZER, ourConfig.remove(REFLECTION_OPTIMIZATION_ENABLED) );
+      setUnlessNull( settings, Environment.GENERATE_STATISTICS, ourConfig.remove(STAT_GENERATION_ENABLED) );
+      setUnlessNull( settings, Environment.DEFAULT_CATALOG, ourConfig.remove(DEFAULT_CATALOG) );
+      setUnlessNull( settings, Environment.USE_SECOND_LEVEL_CACHE, ourConfig.remove(SECOND_LEVEL_CACHE_ENABLED) );
+      setUnlessNull( settings, org.hibernate.cache.jbc2.builder.JndiMultiplexingCacheInstanceManager.CACHE_FACTORY_RESOURCE_PROP, ourConfig.remove(DEPLOYED_CACHE_MANAGER_JNDI_NAME));
+      setUnlessNull( settings, org.hibernate.cache.jbc2.builder.JndiSharedCacheInstanceManager.CACHE_RESOURCE_PROP, ourConfig.remove(DEPLOYED_CACHE_JNDI_NAME));
+      
+      // Set any remaining properties; presumably these are standard
+      // Hibernate configuration properties
+      for (Map.Entry<String, Object> entry : ourConfig.entrySet())
+      {
+         setUnlessNull( settings, entry.getKey(), entry.getValue() );
+      }
    }
 
    /**
@@ -442,28 +589,31 @@
     */
    private void bind() throws HibernateException
    {
-      InitialContext ctx = null;
-      try
+      if (bindInJndi)
       {
-         ctx = new InitialContext();
-         Util.bind( ctx, sessionFactoryName, sessionFactory );
-      }
-      catch ( NamingException e )
-      {
-         throw new HibernateException( "Unable to bind SessionFactory into JNDI", e );
-      }
-      finally
-      {
-         if ( ctx != null )
+         InitialContext ctx = null;
+         try
          {
-            try
+            ctx = new InitialContext();
+            Util.bind( ctx, sessionFactoryName, sessionFactory );
+         }
+         catch ( NamingException e )
+         {
+            throw new HibernateException( "Unable to bind SessionFactory into JNDI", e );
+         }
+         finally
+         {
+            if ( ctx != null )
             {
-               ctx.close();
+               try
+               {
+                  ctx.close();
+               }
+               catch ( Throwable ignore )
+               {
+                  // ignore
+               }
             }
-            catch ( Throwable ignore )
-            {
-               // ignore
-            }
          }
       }
    }
@@ -475,28 +625,31 @@
     */
    private void unbind() throws HibernateException
    {
-      InitialContext ctx = null;
-      try
+      if (bindInJndi)
       {
-         ctx = new InitialContext();
-         Util.unbind( ctx, sessionFactoryName );
-      }
-      catch ( NamingException e )
-      {
-         throw new HibernateException( "Unable to unbind SessionFactory from JNDI", e );
-      }
-      finally
-      {
-         if ( ctx != null )
+         InitialContext ctx = null;
+         try
          {
-            try
+            ctx = new InitialContext();
+            Util.unbind( ctx, sessionFactoryName );
+         }
+         catch ( NamingException e )
+         {
+            throw new HibernateException( "Unable to unbind SessionFactory from JNDI", e );
+         }
+         finally
+         {
+            if ( ctx != null )
             {
-               ctx.close();
+               try
+               {
+                  ctx.close();
+               }
+               catch ( Throwable ignore )
+               {
+                  // ignore
+               }
             }
-            catch ( Throwable ignore )
-            {
-               // ignore
-            }
          }
       }
    }
@@ -543,7 +696,7 @@
 
    public String getVersion()
    {
-      return Environment.VERSION;
+      return Version.getVersionString();
    }
 
    public SessionFactory getInstance()
@@ -576,172 +729,157 @@
 
    public String getDatasourceName()
    {
-      return datasourceName;
+      return getConfigurationElementAsString(DATASOURCE_NAME, Environment.DATASOURCE);
    }
 
    public void setDatasourceName(String datasourceName)
    {
-      this.datasourceName = datasourceName;
-      dirty = true;
+      setConfigurationElement(datasourceName, DATASOURCE_NAME, Environment.DATASOURCE);
    }
 
    public String getUsername()
    {
-      return username;
+      return getConfigurationElementAsString(USERNAME, Environment.USER);
    }
 
    public void setUsername(String username)
    {
-      this.username = username;
-      dirty = true;
+      setConfigurationElement( username, USERNAME, Environment.USER );
    }
 
    public void setPassword(String password)
    {
-      this.password = password;
-      dirty = true;
+      setConfigurationElement( password, PASSWORD, Environment.PASS ); 
    }
 
    public String getDefaultSchema()
    {
-      return defaultSchema;
+      return getConfigurationElementAsString(DEFAULT_SCHEMA, Environment.DEFAULT_SCHEMA);
    }
 
    public void setDefaultSchema(String defaultSchema)
    {
-      this.defaultSchema = defaultSchema;
-      dirty = true;
+      setConfigurationElement(defaultSchema, DEFAULT_SCHEMA, Environment.DEFAULT_SCHEMA);
    }
 
    public String getDefaultCatalog()
    {
-      return defaultCatalog;
+      return getConfigurationElementAsString(DEFAULT_CATALOG, Environment.DEFAULT_CATALOG);
    }
 
    public void setDefaultCatalog(String defaultCatalog)
    {
-      this.defaultCatalog = defaultCatalog;
+      setConfigurationElement( defaultCatalog, DEFAULT_CATALOG, Environment.DEFAULT_CATALOG);
    }
 
    public String getHbm2ddlAuto()
    {
-      return hbm2ddlAuto;
+      return getConfigurationElementAsString(HBM2DDL_AUTO, Environment.HBM2DDL_AUTO);
    }
 
    public void setHbm2ddlAuto(String hbm2ddlAuto)
    {
-      this.hbm2ddlAuto = hbm2ddlAuto;
-      dirty = true;
+      setConfigurationElement(hbm2ddlAuto, HBM2DDL_AUTO, Environment.HBM2DDL_AUTO);
    }
 
    public String getDialect()
    {
-      return dialect;
+      return getConfigurationElementAsString(DIALECT, Environment.DIALECT);
    }
 
    public void setDialect(String dialect)
    {
-      this.dialect = dialect;
-      dirty = true;
+      setConfigurationElement(dialect, DIALECT, Environment.DIALECT);
    }
 
    public Integer getMaxFetchDepth()
    {
-      return maxFetchDepth;
+      return getConfigurationElementAsInteger(MAX_FETCH_DEPTH, Environment.MAX_FETCH_DEPTH);
    }
 
    public void setMaxFetchDepth(Integer maxFetchDepth)
    {
-      this.maxFetchDepth = maxFetchDepth;
-      dirty = true;
+      setConfigurationElement( maxFetchDepth, MAX_FETCH_DEPTH, Environment.MAX_FETCH_DEPTH);
    }
 
    public Integer getJdbcBatchSize()
    {
-      return jdbcBatchSize;
+      return getConfigurationElementAsInteger(JDBC_BATCH_SIZE, Environment.STATEMENT_BATCH_SIZE );
    }
 
    public void setJdbcBatchSize(Integer jdbcBatchSize)
    {
-      this.jdbcBatchSize = jdbcBatchSize;
-      dirty = true;
+      setConfigurationElement( jdbcBatchSize, JDBC_BATCH_SIZE, Environment.STATEMENT_BATCH_SIZE );
    }
 
    public Integer getJdbcFetchSize()
    {
-      return jdbcFetchSize;
+      return getConfigurationElementAsInteger(JDBC_FETCH_SIZE, Environment.STATEMENT_FETCH_SIZE);
    }
 
    public void setJdbcFetchSize(Integer jdbcFetchSize)
    {
-      this.jdbcFetchSize = jdbcFetchSize;
-      dirty = true;
+      setConfigurationElement(jdbcFetchSize, JDBC_FETCH_SIZE, Environment.STATEMENT_FETCH_SIZE);
    }
 
    public Boolean getJdbcScrollableResultSetEnabled()
    {
-      return jdbcScrollableResultSetEnabled;
+      return getConfigurationElementAsBoolean(JDBC_SCROLLABLE_RESULT_SET_ENABLED, Environment.USE_SCROLLABLE_RESULTSET);
    }
 
    public void setJdbcScrollableResultSetEnabled(Boolean jdbcScrollableResultSetEnabled)
    {
-      this.jdbcScrollableResultSetEnabled = jdbcScrollableResultSetEnabled;
-      dirty = true;
+      setConfigurationElement(jdbcScrollableResultSetEnabled, JDBC_SCROLLABLE_RESULT_SET_ENABLED, Environment.USE_SCROLLABLE_RESULTSET);
    }
 
    public Boolean getGetGeneratedKeysEnabled()
    {
-      return getGeneratedKeysEnabled;
+      return getConfigurationElementAsBoolean(GET_GENERATED_KEYS_ENABLED, Environment.USE_GET_GENERATED_KEYS);
    }
 
    public void setGetGeneratedKeysEnabled(Boolean getGeneratedKeysEnabled)
    {
-      this.getGeneratedKeysEnabled = getGeneratedKeysEnabled;
-      dirty = true;
+      setConfigurationElement( getGeneratedKeysEnabled, GET_GENERATED_KEYS_ENABLED, Environment.USE_GET_GENERATED_KEYS);
    }
 
    public String getQuerySubstitutions()
    {
-      return querySubstitutions;
+      return getConfigurationElementAsString(QUERY_SUBSTITUTIONS, Environment.QUERY_SUBSTITUTIONS);
    }
 
    public void setQuerySubstitutions(String querySubstitutions)
    {
-      this.querySubstitutions = querySubstitutions;
-      dirty = true;
+      setConfigurationElement(querySubstitutions, QUERY_SUBSTITUTIONS, Environment.QUERY_SUBSTITUTIONS);
    }
 
    public Boolean getSecondLevelCacheEnabled()
    {
-      return secondLevelCacheEnabled;
+      return getConfigurationElementAsBoolean(SECOND_LEVEL_CACHE_ENABLED, Environment.USE_SECOND_LEVEL_CACHE);
    }
 
    public void setSecondLevelCacheEnabled(Boolean secondLevelCacheEnabled)
    {
-      this.secondLevelCacheEnabled = secondLevelCacheEnabled;
-      dirty = true;
+      setConfigurationElement( secondLevelCacheEnabled, SECOND_LEVEL_CACHE_ENABLED, Environment.USE_SECOND_LEVEL_CACHE);
    }
 
    public Boolean getQueryCacheEnabled()
    {
-      return queryCacheEnabled;
+      return getConfigurationElementAsBoolean(QUERY_CACHE_ENABLED, Environment.USE_QUERY_CACHE);
    }
 
    public void setQueryCacheEnabled(Boolean queryCacheEnabled)
    {
-      this.queryCacheEnabled = queryCacheEnabled;
-      dirty = true;
+      setConfigurationElement(queryCacheEnabled, QUERY_CACHE_ENABLED, Environment.USE_QUERY_CACHE);
    }
 
    public String getCacheProviderClass()
    {
-      return cacheProviderClass;
+      return getConfigurationElementAsString(CACHE_PROVIDER_CLASS, Environment.CACHE_PROVIDER);
    }
 
    public void setCacheProviderClass(String cacheProviderClass)
    {
-      this.cacheProviderClass = cacheProviderClass;
-      dirty = true;
+      setConfigurationElement(cacheProviderClass,CACHE_PROVIDER_CLASS, Environment.CACHE_PROVIDER);
    }
 
    /**
@@ -749,7 +887,7 @@
     */
    public String getCacheRegionFactoryClass()
    {
-      return this.cacheRegionFactoryClass;
+      return getConfigurationElementAsString(CACHE_REGION_FACTORY_CLASS, Environment.CACHE_REGION_FACTORY);
    }
 
    /**
@@ -757,61 +895,57 @@
     */
    public void setCacheRegionFactoryClass(String regionFactoryClass)
    {
-      this.cacheRegionFactoryClass = regionFactoryClass;
-      dirty = true;
+      setConfigurationElement(regionFactoryClass, CACHE_REGION_FACTORY_CLASS, Environment.CACHE_REGION_FACTORY);
    }
 
    public String getCacheRegionPrefix()
    {
-      return cacheRegionPrefix;
+      return getConfigurationElementAsString(CACHE_REGION_PREFIX, Environment.CACHE_REGION_PREFIX);
    }
 
    public void setCacheRegionPrefix(String cacheRegionPrefix)
    {
-      this.cacheRegionPrefix = cacheRegionPrefix;
-      dirty = true;
+      setConfigurationElement(cacheRegionPrefix, CACHE_REGION_PREFIX, Environment.CACHE_REGION_PREFIX);
    }
 
    public Boolean getMinimalPutsEnabled()
    {
-      return minimalPutsEnabled;
+      return getConfigurationElementAsBoolean(MINIMAL_PUTS_ENABLED, Environment.USE_MINIMAL_PUTS);
    }
 
    public void setMinimalPutsEnabled(Boolean minimalPutsEnabled)
    {
-      this.minimalPutsEnabled = minimalPutsEnabled;
-      dirty = true;
+      setConfigurationElement(minimalPutsEnabled, MINIMAL_PUTS_ENABLED, Environment.USE_MINIMAL_PUTS);
    }
 
    public Boolean getUseStructuredCacheEntriesEnabled()
    {
-      return structuredCacheEntriesEnabled;
+      return getConfigurationElementAsBoolean(STRUCTURED_CACHE_ENTRIES_ENABLED, Environment.USE_STRUCTURED_CACHE);
    }
 
    public void setUseStructuredCacheEntriesEnabled(Boolean structuredCacheEntriesEnabled)
    {
-      this.structuredCacheEntriesEnabled = structuredCacheEntriesEnabled;
+      setConfigurationElement(structuredCacheEntriesEnabled, STRUCTURED_CACHE_ENTRIES_ENABLED, Environment.USE_STRUCTURED_CACHE);
    }
 
    public Boolean getShowSqlEnabled()
    {
-      return showSqlEnabled;
+      return getConfigurationElementAsBoolean(SHOW_SQL_ENABLED, Environment.SHOW_SQL);
    }
 
    public void setShowSqlEnabled(Boolean showSqlEnabled)
    {
-      this.showSqlEnabled = showSqlEnabled;
-      dirty = true;
+      setConfigurationElement( showSqlEnabled, SHOW_SQL_ENABLED, Environment.SHOW_SQL);
    }
 
    public Boolean getSqlCommentsEnabled()
    {
-      return sqlCommentsEnabled;
+      return getConfigurationElementAsBoolean(SQL_COMMENTS_ENABLED, Environment.USE_SQL_COMMENTS);
    }
 
    public void setSqlCommentsEnabled(Boolean commentsEnabled)
    {
-      this.sqlCommentsEnabled = commentsEnabled;
+      setConfigurationElement( commentsEnabled, SQL_COMMENTS_ENABLED, Environment.USE_SQL_COMMENTS);
    }
 
    public String getSessionFactoryInterceptor()
@@ -840,7 +974,7 @@
     */
    public String getDeployedCacheJndiName()
    {
-      return this.deployedCacheJndiName;
+      return getConfigurationElementAsString(DEPLOYED_CACHE_JNDI_NAME, org.hibernate.cache.jbc2.builder.JndiSharedCacheInstanceManager.CACHE_RESOURCE_PROP);
    }
 
    /**
@@ -848,8 +982,7 @@
     */
    public void setDeployedCacheJndiName(String name)
    {
-      this.deployedCacheJndiName = name;
-      dirty = true;
+      setConfigurationElement( name, DEPLOYED_CACHE_JNDI_NAME, org.hibernate.cache.jbc2.builder.JndiSharedCacheInstanceManager.CACHE_RESOURCE_PROP);
    }
 
    /**
@@ -857,7 +990,7 @@
     */
    public String getDeployedCacheManagerJndiName()
    {
-      return this.deployedCacheManagerJndiName;
+      return getConfigurationElementAsString(DEPLOYED_CACHE_MANAGER_JNDI_NAME, org.hibernate.cache.jbc2.builder.JndiMultiplexingCacheInstanceManager.CACHE_FACTORY_RESOURCE_PROP);
    }
 
    /**
@@ -865,51 +998,47 @@
     */
    public void setDeployedCacheManagerJndiName(String name)
    {
-      this.deployedCacheManagerJndiName = name;
-      dirty = true;
+      setConfigurationElement( name, DEPLOYED_CACHE_MANAGER_JNDI_NAME, org.hibernate.cache.jbc2.builder.JndiMultiplexingCacheInstanceManager.CACHE_FACTORY_RESOURCE_PROP);
    }
 
    public Boolean getBatchVersionedDataEnabled()
    {
-      return batchVersionedDataEnabled;
+      return getConfigurationElementAsBoolean(BATCH_VERSIONED_DATA_ENABLED, Environment.BATCH_VERSIONED_DATA);
    }
 
    public void setBatchVersionedDataEnabled(Boolean batchVersionedDataEnabled)
    {
-      this.batchVersionedDataEnabled = batchVersionedDataEnabled;
-      this.dirty = true;
+      setConfigurationElement( batchVersionedDataEnabled, BATCH_VERSIONED_DATA_ENABLED, Environment.BATCH_VERSIONED_DATA);
    }
 
    public Boolean getStreamsForBinaryEnabled()
    {
-      return streamsForBinaryEnabled;
+      return getConfigurationElementAsBoolean(STREAMS_FOR_BINARY_ENABLED, Environment.USE_STREAMS_FOR_BINARY);
    }
 
    public void setStreamsForBinaryEnabled(Boolean streamsForBinaryEnabled)
    {
-      this.streamsForBinaryEnabled = streamsForBinaryEnabled;
-      this.dirty = true;
+      setConfigurationElement( streamsForBinaryEnabled, STREAMS_FOR_BINARY_ENABLED, Environment.USE_STREAMS_FOR_BINARY);
    }
 
    public Boolean getReflectionOptimizationEnabled()
    {
-      return reflectionOptimizationEnabled;
+      return getConfigurationElementAsBoolean(REFLECTION_OPTIMIZATION_ENABLED, Environment.USE_REFLECTION_OPTIMIZER);
    }
 
    public void setReflectionOptimizationEnabled(Boolean reflectionOptimizationEnabled)
    {
-      this.reflectionOptimizationEnabled = reflectionOptimizationEnabled;
-      this.dirty = true;
+      setConfigurationElement( reflectionOptimizationEnabled, REFLECTION_OPTIMIZATION_ENABLED, Environment.USE_REFLECTION_OPTIMIZER);
    }
 
    public Boolean getStatGenerationEnabled()
    {
-      return statGenerationEnabled;
+      return getConfigurationElementAsBoolean(STAT_GENERATION_ENABLED, Environment.GENERATE_STATISTICS);
    }
 
    public void setStatGenerationEnabled(Boolean statGenerationEnabled)
    {
-      this.statGenerationEnabled = statGenerationEnabled;
+      setConfigurationElement( statGenerationEnabled, STAT_GENERATION_ENABLED, Environment.GENERATE_STATISTICS);
    }
 
    public URL getHarUrl()
@@ -932,4 +1061,54 @@
    {
       this.scanForMappingsEnabled = scanForMappingsEnabled;
    }
+   
+   private String getConfigurationElementAsString(String beanPropertyName, String hibernateName)
+   {
+      Object element = getConfigurationElement(beanPropertyName, hibernateName);
+      return element == null ? null : element.toString();
+   }
+   
+   private Boolean getConfigurationElementAsBoolean(String beanPropertyName, String hibernateName)
+   {
+      Object element = getConfigurationElement(beanPropertyName, hibernateName);
+      if (element instanceof String)
+      {
+         return Boolean.valueOf((String) element);
+      }
+      return (Boolean) element;
+   }
+   
+   private Integer getConfigurationElementAsInteger(String beanPropertyName, String hibernateName)
+   {
+      Object element = getConfigurationElement(beanPropertyName, hibernateName);
+      if (element instanceof String)
+      {
+         return Integer.valueOf((String) element);
+      }
+      return (Integer) element;
+   }
+   
+   private Object getConfigurationElement(String beanPropertyName, String hibernateName)
+   {
+      Object name = configurationElements.get(beanPropertyName);
+      if (name == null)
+      {
+         name = configurationElements.get(hibernateName);
+      }
+      return name;
+   }
+   
+   private void setConfigurationElement(Object value, String beanPropertyName, String hibernateName)
+   {
+      configurationElements.remove(beanPropertyName);
+      if (value == null)
+      {
+         configurationElements.remove(hibernateName);
+      }
+      else
+      {
+         configurationElements.put(hibernateName, value);
+      }
+      dirty = true;
+   }
 }

Modified: branches/JBPAPP_5_1/testsuite/.classpath
===================================================================
--- branches/JBPAPP_5_1/testsuite/.classpath	2010-05-07 21:32:05 UTC (rev 104584)
+++ branches/JBPAPP_5_1/testsuite/.classpath	2010-05-07 22:24:51 UTC (rev 104585)
@@ -60,5 +60,6 @@
 	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-ejb3-proxy-impl/lib/jboss-ejb3-proxy-impl.jar" sourcepath="/thirdparty/jboss/jboss-ejb3-proxy-impl/lib/jboss-ejb3-proxy-impl-sources.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-ejb3-proxy-spi/lib/jboss-ejb3-proxy-spi.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/jbossts/lib/jbossjts-integration.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/hibernate/lib/hibernate-jbosscache2.jar" sourcepath="/thirdparty/hibernate/lib/hibernate-jbosscache2-sources.jar"/>
 	<classpathentry kind="output" path="output/eclipse-classes"/>
 </classpath>

Modified: branches/JBPAPP_5_1/testsuite/imports/sections/hibernate.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/imports/sections/hibernate.xml	2010-05-07 21:32:05 UTC (rev 104584)
+++ branches/JBPAPP_5_1/testsuite/imports/sections/hibernate.xml	2010-05-07 22:24:51 UTC (rev 104585)
@@ -88,5 +88,23 @@
          </metainf>
          <include name="hib-ejb2.jar"/>
       </jar>
+      
+      <jar basedir="${build.classes}" destfile="${build.lib}/hib-jbas7411.har">
+         <metainf dir="${build.resources}/hibernate/jbas7411">
+            <include name="jboss-hibernate.xml"/>
+            <include name="Timers.hbm.xml"/>
+         </metainf>
+         <include name="org/jboss/test/hibernate/SimpleInterceptor.class"/>
+      </jar>
+      <jar basedir="${build.classes}" destfile="${build.lib}/hib-jbas7411.jar">
+         <metainf dir="${build.resources}/hibernate/ejbtimers">
+            <include name="ejb-jar.xml"/>
+            <include name="jboss.xml"/>
+         </metainf>
+         <include name="org/jboss/test/hibernate/timers/**"/>
+         <fileset dir="${build.lib}">
+            <include name="hib-jbas7411.har"/>
+         </fileset>
+      </jar>
    </target>
 </project>

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/CacheManagerUnitTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/CacheManagerUnitTestCase.java	2010-05-07 21:32:05 UTC (rev 104584)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/CacheManagerUnitTestCase.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -185,10 +185,15 @@
       
       // One release does not cause registry to stop cache
       assertEquals(CacheStatus.STARTED, cache.getCacheStatus());
-      
+
       registry.stop();
       
-      // Now it's stopped
+      // Should still not be stopped
+      assertEquals(CacheStatus.STARTED, cache.getCacheStatus());
+
+      registry.releaseCache(configName);
+
+      // Now it should be stopped
       assertEquals(CacheStatus.DESTROYED, cache.getCacheStatus());
       caches.remove(cache);
       
@@ -278,10 +283,15 @@
       
       // One release does not cause registry to stop cache
       assertEquals(CacheStatus.STARTED, cache.getCache().getCacheStatus());
-      
+
       registry.stop();
-      
-      // Now it's stopped
+
+      // Should still not be stopped
+      assertEquals(CacheStatus.STARTED, cache.getCache().getCacheStatus());
+
+      registry.releaseCache(configName);
+
+      // Now it should be stopped
       assertEquals(CacheStatus.DESTROYED, cache.getCache().getCacheStatus());
       caches.remove(cache);
       

Copied: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks (from rev 96511, branches/Branch_5_x/testsuite/src/main/org/jboss/test/hibernate/mocks)

Deleted: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCache.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCache.java	2009-11-18 22:53:20 UTC (rev 96511)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCache.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -1,142 +0,0 @@
-/**
- * 
- */
-package org.jboss.test.hibernate.mocks;
-
-import java.util.Map;
-
-import org.hibernate.cache.Cache;
-import org.hibernate.cache.CacheException;
-
-/**
- * A MockCache.
- * 
- * @author Brian Stansberry
- * @version $Revision: 1.1 $
- */
-public class MockCache implements Cache
-{
-   public static final MockCache instance = new MockCache();
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Cache#clear()
-    */
-   public void clear() throws CacheException
-   {
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Cache#destroy()
-    */
-   public void destroy() throws CacheException
-   {
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Cache#get(java.lang.Object)
-    */
-   public Object get(Object key) throws CacheException
-   {
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Cache#getElementCountInMemory()
-    */
-   public long getElementCountInMemory()
-   {
-      return 0;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Cache#getElementCountOnDisk()
-    */
-   public long getElementCountOnDisk()
-   {
-      return 0;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Cache#getRegionName()
-    */
-   public String getRegionName()
-   {
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Cache#getSizeInMemory()
-    */
-   public long getSizeInMemory()
-   {
-      return 0;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Cache#getTimeout()
-    */
-   public int getTimeout()
-   {
-      return 0;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Cache#lock(java.lang.Object)
-    */
-   public void lock(Object key) throws CacheException
-   {
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Cache#nextTimestamp()
-    */
-   public long nextTimestamp()
-   {
-      return 0;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Cache#put(java.lang.Object, java.lang.Object)
-    */
-   public void put(Object key, Object value) throws CacheException
-   {
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Cache#read(java.lang.Object)
-    */
-   public Object read(Object key) throws CacheException
-   {
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Cache#remove(java.lang.Object)
-    */
-   public void remove(Object key) throws CacheException
-   {
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Cache#toMap()
-    */
-   public Map toMap()
-   {
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Cache#unlock(java.lang.Object)
-    */
-   public void unlock(Object key) throws CacheException
-   {
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Cache#update(java.lang.Object, java.lang.Object)
-    */
-   public void update(Object key, Object value) throws CacheException
-   {
-   }
-
-}

Copied: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCache.java (from rev 96511, branches/Branch_5_x/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCache.java)
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCache.java	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCache.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -0,0 +1,142 @@
+/**
+ * 
+ */
+package org.jboss.test.hibernate.mocks;
+
+import java.util.Map;
+
+import org.hibernate.cache.Cache;
+import org.hibernate.cache.CacheException;
+
+/**
+ * A MockCache.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision: 1.1 $
+ */
+public class MockCache implements Cache
+{
+   public static final MockCache instance = new MockCache();
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Cache#clear()
+    */
+   public void clear() throws CacheException
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Cache#destroy()
+    */
+   public void destroy() throws CacheException
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Cache#get(java.lang.Object)
+    */
+   public Object get(Object key) throws CacheException
+   {
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Cache#getElementCountInMemory()
+    */
+   public long getElementCountInMemory()
+   {
+      return 0;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Cache#getElementCountOnDisk()
+    */
+   public long getElementCountOnDisk()
+   {
+      return 0;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Cache#getRegionName()
+    */
+   public String getRegionName()
+   {
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Cache#getSizeInMemory()
+    */
+   public long getSizeInMemory()
+   {
+      return 0;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Cache#getTimeout()
+    */
+   public int getTimeout()
+   {
+      return 0;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Cache#lock(java.lang.Object)
+    */
+   public void lock(Object key) throws CacheException
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Cache#nextTimestamp()
+    */
+   public long nextTimestamp()
+   {
+      return 0;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Cache#put(java.lang.Object, java.lang.Object)
+    */
+   public void put(Object key, Object value) throws CacheException
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Cache#read(java.lang.Object)
+    */
+   public Object read(Object key) throws CacheException
+   {
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Cache#remove(java.lang.Object)
+    */
+   public void remove(Object key) throws CacheException
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Cache#toMap()
+    */
+   public Map toMap()
+   {
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Cache#unlock(java.lang.Object)
+    */
+   public void unlock(Object key) throws CacheException
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Cache#update(java.lang.Object, java.lang.Object)
+    */
+   public void update(Object key, Object value) throws CacheException
+   {
+   }
+
+}

Deleted: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCacheProvider.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCacheProvider.java	2009-11-18 22:53:20 UTC (rev 96511)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCacheProvider.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -1,60 +0,0 @@
-/**
- * 
- */
-package org.jboss.test.hibernate.mocks;
-
-import java.util.Properties;
-
-import org.hibernate.cache.Cache;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.CacheProvider;
-
-/**
- * A MockCacheProvider.
- * 
- * @author Brian Stansberry
- * @version $Revision: 1.1 $
- */
-public class MockCacheProvider implements CacheProvider
-{
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.CacheProvider#buildCache(java.lang.String, java.util.Properties)
-    */
-   public Cache buildCache(String regionName, Properties properties) throws CacheException
-   {
-      return MockCache.instance;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.CacheProvider#isMinimalPutsEnabledByDefault()
-    */
-   public boolean isMinimalPutsEnabledByDefault()
-   {
-      return false;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.CacheProvider#nextTimestamp()
-    */
-   public long nextTimestamp()
-   {
-      return 0;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.CacheProvider#start(java.util.Properties)
-    */
-   public void start(Properties properties) throws CacheException
-   {
-
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.CacheProvider#stop()
-    */
-   public void stop()
-   {
-   }
-
-}

Copied: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCacheProvider.java (from rev 96511, branches/Branch_5_x/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCacheProvider.java)
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCacheProvider.java	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockCacheProvider.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -0,0 +1,60 @@
+/**
+ * 
+ */
+package org.jboss.test.hibernate.mocks;
+
+import java.util.Properties;
+
+import org.hibernate.cache.Cache;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.CacheProvider;
+
+/**
+ * A MockCacheProvider.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision: 1.1 $
+ */
+public class MockCacheProvider implements CacheProvider
+{
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.CacheProvider#buildCache(java.lang.String, java.util.Properties)
+    */
+   public Cache buildCache(String regionName, Properties properties) throws CacheException
+   {
+      return MockCache.instance;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.CacheProvider#isMinimalPutsEnabledByDefault()
+    */
+   public boolean isMinimalPutsEnabledByDefault()
+   {
+      return false;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.CacheProvider#nextTimestamp()
+    */
+   public long nextTimestamp()
+   {
+      return 0;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.CacheProvider#start(java.util.Properties)
+    */
+   public void start(Properties properties) throws CacheException
+   {
+
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.CacheProvider#stop()
+    */
+   public void stop()
+   {
+   }
+
+}

Deleted: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockInterceptor.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/hibernate/mocks/MockInterceptor.java	2009-11-18 22:53:20 UTC (rev 96511)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockInterceptor.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -1,182 +0,0 @@
-/**
- * 
- */
-package org.jboss.test.hibernate.mocks;
-
-import java.io.Serializable;
-import java.util.Iterator;
-
-import org.hibernate.CallbackException;
-import org.hibernate.EntityMode;
-import org.hibernate.Interceptor;
-import org.hibernate.Transaction;
-import org.hibernate.type.Type;
-
-/**
- * A MockInterceptor.
- * 
- * @author Brian Stansberry
- * @version $Revision: 1.1 $
- */
-public class MockInterceptor implements Interceptor
-{
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#afterTransactionBegin(org.hibernate.Transaction)
-    */
-   public void afterTransactionBegin(Transaction tx)
-   {
-      // no-op
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#afterTransactionCompletion(org.hibernate.Transaction)
-    */
-   public void afterTransactionCompletion(Transaction tx)
-   {
-      // no-op
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#beforeTransactionCompletion(org.hibernate.Transaction)
-    */
-   public void beforeTransactionCompletion(Transaction tx)
-   {
-      // no-op
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#findDirty(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.Object[], java.lang.String[], org.hibernate.type.Type[])
-    */
-   public int[] findDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
-         String[] propertyNames, Type[] types)
-   {
-      // no-op
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#getEntity(java.lang.String, java.io.Serializable)
-    */
-   public Object getEntity(String entityName, Serializable id) throws CallbackException
-   {
-      // no-op
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#getEntityName(java.lang.Object)
-    */
-   public String getEntityName(Object object) throws CallbackException
-   {
-      // no-op
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#instantiate(java.lang.String, org.hibernate.EntityMode, java.io.Serializable)
-    */
-   public Object instantiate(String entityName, EntityMode entityMode, Serializable id) throws CallbackException
-   {
-      // no-op
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#isTransient(java.lang.Object)
-    */
-   public Boolean isTransient(Object entity)
-   {
-      // no-op
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#onCollectionRecreate(java.lang.Object, java.io.Serializable)
-    */
-   public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException
-   {
-      // no-op
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#onCollectionRemove(java.lang.Object, java.io.Serializable)
-    */
-   public void onCollectionRemove(Object collection, Serializable key) throws CallbackException
-   {
-      // no-op
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#onCollectionUpdate(java.lang.Object, java.io.Serializable)
-    */
-   public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException
-   {
-      // no-op
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#onDelete(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.String[], org.hibernate.type.Type[])
-    */
-   public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
-         throws CallbackException
-   {
-      // no-op
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#onFlushDirty(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.Object[], java.lang.String[], org.hibernate.type.Type[])
-    */
-   public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
-         String[] propertyNames, Type[] types) throws CallbackException
-   {
-      // no-op
-      return false;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#onLoad(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.String[], org.hibernate.type.Type[])
-    */
-   public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
-         throws CallbackException
-   {
-      // no-op
-      return false;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#onPrepareStatement(java.lang.String)
-    */
-   public String onPrepareStatement(String sql)
-   {
-      // no-op
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#onSave(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.String[], org.hibernate.type.Type[])
-    */
-   public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
-         throws CallbackException
-   {
-      // no-op
-      return false;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#postFlush(java.util.Iterator)
-    */
-   public void postFlush(Iterator entities) throws CallbackException
-   {
-      // no-op
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.Interceptor#preFlush(java.util.Iterator)
-    */
-   public void preFlush(Iterator entities) throws CallbackException
-   {
-      // no-op
-   }
-
-}

Copied: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockInterceptor.java (from rev 96511, branches/Branch_5_x/testsuite/src/main/org/jboss/test/hibernate/mocks/MockInterceptor.java)
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockInterceptor.java	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockInterceptor.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -0,0 +1,182 @@
+/**
+ * 
+ */
+package org.jboss.test.hibernate.mocks;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+import org.hibernate.CallbackException;
+import org.hibernate.EntityMode;
+import org.hibernate.Interceptor;
+import org.hibernate.Transaction;
+import org.hibernate.type.Type;
+
+/**
+ * A MockInterceptor.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision: 1.1 $
+ */
+public class MockInterceptor implements Interceptor
+{
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#afterTransactionBegin(org.hibernate.Transaction)
+    */
+   public void afterTransactionBegin(Transaction tx)
+   {
+      // no-op
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#afterTransactionCompletion(org.hibernate.Transaction)
+    */
+   public void afterTransactionCompletion(Transaction tx)
+   {
+      // no-op
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#beforeTransactionCompletion(org.hibernate.Transaction)
+    */
+   public void beforeTransactionCompletion(Transaction tx)
+   {
+      // no-op
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#findDirty(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.Object[], java.lang.String[], org.hibernate.type.Type[])
+    */
+   public int[] findDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
+         String[] propertyNames, Type[] types)
+   {
+      // no-op
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#getEntity(java.lang.String, java.io.Serializable)
+    */
+   public Object getEntity(String entityName, Serializable id) throws CallbackException
+   {
+      // no-op
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#getEntityName(java.lang.Object)
+    */
+   public String getEntityName(Object object) throws CallbackException
+   {
+      // no-op
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#instantiate(java.lang.String, org.hibernate.EntityMode, java.io.Serializable)
+    */
+   public Object instantiate(String entityName, EntityMode entityMode, Serializable id) throws CallbackException
+   {
+      // no-op
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#isTransient(java.lang.Object)
+    */
+   public Boolean isTransient(Object entity)
+   {
+      // no-op
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#onCollectionRecreate(java.lang.Object, java.io.Serializable)
+    */
+   public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException
+   {
+      // no-op
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#onCollectionRemove(java.lang.Object, java.io.Serializable)
+    */
+   public void onCollectionRemove(Object collection, Serializable key) throws CallbackException
+   {
+      // no-op
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#onCollectionUpdate(java.lang.Object, java.io.Serializable)
+    */
+   public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException
+   {
+      // no-op
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#onDelete(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.String[], org.hibernate.type.Type[])
+    */
+   public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
+         throws CallbackException
+   {
+      // no-op
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#onFlushDirty(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.Object[], java.lang.String[], org.hibernate.type.Type[])
+    */
+   public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
+         String[] propertyNames, Type[] types) throws CallbackException
+   {
+      // no-op
+      return false;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#onLoad(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.String[], org.hibernate.type.Type[])
+    */
+   public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
+         throws CallbackException
+   {
+      // no-op
+      return false;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#onPrepareStatement(java.lang.String)
+    */
+   public String onPrepareStatement(String sql)
+   {
+      // no-op
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#onSave(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.String[], org.hibernate.type.Type[])
+    */
+   public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
+         throws CallbackException
+   {
+      // no-op
+      return false;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#postFlush(java.util.Iterator)
+    */
+   public void postFlush(Iterator entities) throws CallbackException
+   {
+      // no-op
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.Interceptor#preFlush(java.util.Iterator)
+    */
+   public void preFlush(Iterator entities) throws CallbackException
+   {
+      // no-op
+   }
+
+}

Deleted: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockListenerInjector.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/hibernate/mocks/MockListenerInjector.java	2009-11-18 22:53:20 UTC (rev 96511)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockListenerInjector.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -1,27 +0,0 @@
-/**
- * 
- */
-package org.jboss.test.hibernate.mocks;
-
-import org.hibernate.cfg.Configuration;
-import org.jboss.deployment.DeploymentException;
-import org.jboss.hibernate.ListenerInjector;
-
-/**
- * A MockListenerInjector.
- * 
- * @author Brian Stansberry
- * @version $Revision: 1.1 $
- */
-public class MockListenerInjector implements ListenerInjector
-{
-
-   /* (non-Javadoc)
-    * @see org.jboss.hibernate.ListenerInjector#injectListeners(java.lang.Object, org.hibernate.cfg.Configuration)
-    */
-   public void injectListeners(Object objectName, Configuration configuration) throws DeploymentException
-   {
-      // no-op
-   }
-
-}

Copied: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockListenerInjector.java (from rev 96511, branches/Branch_5_x/testsuite/src/main/org/jboss/test/hibernate/mocks/MockListenerInjector.java)
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockListenerInjector.java	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockListenerInjector.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -0,0 +1,27 @@
+/**
+ * 
+ */
+package org.jboss.test.hibernate.mocks;
+
+import org.hibernate.cfg.Configuration;
+import org.jboss.deployment.DeploymentException;
+import org.jboss.hibernate.ListenerInjector;
+
+/**
+ * A MockListenerInjector.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision: 1.1 $
+ */
+public class MockListenerInjector implements ListenerInjector
+{
+
+   /* (non-Javadoc)
+    * @see org.jboss.hibernate.ListenerInjector#injectListeners(java.lang.Object, org.hibernate.cfg.Configuration)
+    */
+   public void injectListeners(Object objectName, Configuration configuration) throws DeploymentException
+   {
+      // no-op
+   }
+
+}

Deleted: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegion.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegion.java	2009-11-18 22:53:20 UTC (rev 96511)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegion.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -1,119 +0,0 @@
-/**
- * 
- */
-package org.jboss.test.hibernate.mocks;
-
-import java.util.Map;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.QueryResultsRegion;
-import org.hibernate.cache.TimestampsRegion;
-
-/**
- * A MockQueryResultsRegion.
- * 
- * @author Brian Stansberry
- * @version $Revision: 1.1 $
- */
-public class MockRegion implements QueryResultsRegion, TimestampsRegion
-{
-   public static final MockRegion instance = new MockRegion();
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.GeneralDataRegion#evict(java.lang.Object)
-    */
-   public void evict(Object key) throws CacheException
-   {
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.GeneralDataRegion#evictAll()
-    */
-   public void evictAll() throws CacheException
-   {
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.GeneralDataRegion#get(java.lang.Object)
-    */
-   public Object get(Object key) throws CacheException
-   {
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.GeneralDataRegion#put(java.lang.Object, java.lang.Object)
-    */
-   public void put(Object key, Object value) throws CacheException
-   {
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Region#destroy()
-    */
-   public void destroy() throws CacheException
-   {
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Region#getElementCountInMemory()
-    */
-   public long getElementCountInMemory()
-   {
-      return 0;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Region#getElementCountOnDisk()
-    */
-   public long getElementCountOnDisk()
-   {
-      return 0;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Region#getName()
-    */
-   public String getName()
-   {
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Region#getSizeInMemory()
-    */
-   public long getSizeInMemory()
-   {
-      return 0;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Region#getTimeout()
-    */
-   public int getTimeout()
-   {
-      return 0;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Region#nextTimestamp()
-    */
-   public long nextTimestamp()
-   {
-      return 0;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.Region#toMap()
-    */
-   public Map<?,?> toMap()
-   {
-      return null;
-   }
-
-   public boolean contains(Object key)
-   {
-      return false;
-   }
-
-}

Copied: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegion.java (from rev 96511, branches/Branch_5_x/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegion.java)
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegion.java	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegion.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -0,0 +1,119 @@
+/**
+ * 
+ */
+package org.jboss.test.hibernate.mocks;
+
+import java.util.Map;
+
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.QueryResultsRegion;
+import org.hibernate.cache.TimestampsRegion;
+
+/**
+ * A MockQueryResultsRegion.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision: 1.1 $
+ */
+public class MockRegion implements QueryResultsRegion, TimestampsRegion
+{
+   public static final MockRegion instance = new MockRegion();
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.GeneralDataRegion#evict(java.lang.Object)
+    */
+   public void evict(Object key) throws CacheException
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.GeneralDataRegion#evictAll()
+    */
+   public void evictAll() throws CacheException
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.GeneralDataRegion#get(java.lang.Object)
+    */
+   public Object get(Object key) throws CacheException
+   {
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.GeneralDataRegion#put(java.lang.Object, java.lang.Object)
+    */
+   public void put(Object key, Object value) throws CacheException
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Region#destroy()
+    */
+   public void destroy() throws CacheException
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Region#getElementCountInMemory()
+    */
+   public long getElementCountInMemory()
+   {
+      return 0;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Region#getElementCountOnDisk()
+    */
+   public long getElementCountOnDisk()
+   {
+      return 0;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Region#getName()
+    */
+   public String getName()
+   {
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Region#getSizeInMemory()
+    */
+   public long getSizeInMemory()
+   {
+      return 0;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Region#getTimeout()
+    */
+   public int getTimeout()
+   {
+      return 0;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Region#nextTimestamp()
+    */
+   public long nextTimestamp()
+   {
+      return 0;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.Region#toMap()
+    */
+   public Map<?,?> toMap()
+   {
+      return null;
+   }
+
+   public boolean contains(Object key)
+   {
+      return false;
+   }
+
+}

Deleted: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegionFactory.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegionFactory.java	2009-11-18 22:53:20 UTC (rev 96511)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegionFactory.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -1,95 +0,0 @@
-/**
- * 
- */
-package org.jboss.test.hibernate.mocks;
-
-import java.util.Properties;
-
-import org.hibernate.cache.CacheDataDescription;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.CollectionRegion;
-import org.hibernate.cache.EntityRegion;
-import org.hibernate.cache.QueryResultsRegion;
-import org.hibernate.cache.RegionFactory;
-import org.hibernate.cache.TimestampsRegion;
-import org.hibernate.cfg.Settings;
-
-/**
- * A MockRegionFactory.
- * 
- * @author Brian Stansberry
- * @version $Revision: 1.1 $
- */
-public class MockRegionFactory implements RegionFactory
-{
-
-   public MockRegionFactory(Properties ignored)
-   {
-      super();
-   }
-   
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.RegionFactory#buildCollectionRegion(java.lang.String, java.util.Properties, org.hibernate.cache.CacheDataDescription)
-    */
-   public CollectionRegion buildCollectionRegion(String regionName, Properties properties, CacheDataDescription metadata)
-         throws CacheException
-   {
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.RegionFactory#buildEntityRegion(java.lang.String, java.util.Properties, org.hibernate.cache.CacheDataDescription)
-    */
-   public EntityRegion buildEntityRegion(String regionName, Properties properties, CacheDataDescription metadata)
-         throws CacheException
-   {
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.RegionFactory#buildQueryResultsRegion(java.lang.String, java.util.Properties)
-    */
-   public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException
-   {
-      return MockRegion.instance;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.RegionFactory#buildTimestampsRegion(java.lang.String, java.util.Properties)
-    */
-   public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException
-   {
-      return MockRegion.instance;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.RegionFactory#isMinimalPutsEnabledByDefault()
-    */
-   public boolean isMinimalPutsEnabledByDefault()
-   {
-      return false;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.RegionFactory#nextTimestamp()
-    */
-   public long nextTimestamp()
-   {
-      return 0;
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.RegionFactory#start(org.hibernate.cfg.Settings, java.util.Properties)
-    */
-   public void start(Settings settings, Properties properties) throws CacheException
-   {
-   }
-
-   /* (non-Javadoc)
-    * @see org.hibernate.cache.RegionFactory#stop()
-    */
-   public void stop()
-   {
-   }
-
-}

Copied: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegionFactory.java (from rev 96511, branches/Branch_5_x/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegionFactory.java)
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegionFactory.java	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/MockRegionFactory.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -0,0 +1,95 @@
+/**
+ * 
+ */
+package org.jboss.test.hibernate.mocks;
+
+import java.util.Properties;
+
+import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.CollectionRegion;
+import org.hibernate.cache.EntityRegion;
+import org.hibernate.cache.QueryResultsRegion;
+import org.hibernate.cache.RegionFactory;
+import org.hibernate.cache.TimestampsRegion;
+import org.hibernate.cfg.Settings;
+
+/**
+ * A MockRegionFactory.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision: 1.1 $
+ */
+public class MockRegionFactory implements RegionFactory
+{
+
+   public MockRegionFactory(Properties ignored)
+   {
+      super();
+   }
+   
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.RegionFactory#buildCollectionRegion(java.lang.String, java.util.Properties, org.hibernate.cache.CacheDataDescription)
+    */
+   public CollectionRegion buildCollectionRegion(String regionName, Properties properties, CacheDataDescription metadata)
+         throws CacheException
+   {
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.RegionFactory#buildEntityRegion(java.lang.String, java.util.Properties, org.hibernate.cache.CacheDataDescription)
+    */
+   public EntityRegion buildEntityRegion(String regionName, Properties properties, CacheDataDescription metadata)
+         throws CacheException
+   {
+      return null;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.RegionFactory#buildQueryResultsRegion(java.lang.String, java.util.Properties)
+    */
+   public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException
+   {
+      return MockRegion.instance;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.RegionFactory#buildTimestampsRegion(java.lang.String, java.util.Properties)
+    */
+   public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException
+   {
+      return MockRegion.instance;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.RegionFactory#isMinimalPutsEnabledByDefault()
+    */
+   public boolean isMinimalPutsEnabledByDefault()
+   {
+      return false;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.RegionFactory#nextTimestamp()
+    */
+   public long nextTimestamp()
+   {
+      return 0;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.RegionFactory#start(org.hibernate.cfg.Settings, java.util.Properties)
+    */
+   public void start(Settings settings, Properties properties) throws CacheException
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hibernate.cache.RegionFactory#stop()
+    */
+   public void stop()
+   {
+   }
+
+}

Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/SimpleJtaTransactionImpl.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/SimpleJtaTransactionImpl.java	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/SimpleJtaTransactionImpl.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -0,0 +1,159 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC 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 Middleware LLC.
+ *
+ * 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.jboss.test.hibernate.mocks;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.LinkedList;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.xa.XAResource;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * SimpleJtaTransactionImpl implementation
+ *
+ * @author Steve Ebersole
+ */
+public class SimpleJtaTransactionImpl implements Transaction {
+	private static final Logger log = LoggerFactory.getLogger( SimpleJtaTransactionImpl.class );
+
+	private int status;
+	private LinkedList synchronizations;
+	private Connection connection; // the only resource we care about is jdbc connection
+	private final SimpleJtaTransactionManagerImpl jtaTransactionManager;
+
+	public SimpleJtaTransactionImpl(SimpleJtaTransactionManagerImpl jtaTransactionManager) {
+		this.jtaTransactionManager = jtaTransactionManager;
+		this.status = Status.STATUS_ACTIVE;
+	}
+
+	public int getStatus() {
+		return status;
+	}
+
+	public void commit()
+			throws RollbackException, HeuristicMixedException, HeuristicRollbackException, IllegalStateException, SystemException {
+
+		if ( status == Status.STATUS_MARKED_ROLLBACK ) {
+			log.trace( "on commit, status was marked for rollback-only" );
+			rollback();
+		}
+		else {
+			status = Status.STATUS_PREPARING;
+
+			for ( int i = 0; i < synchronizations.size(); i++ ) {
+				Synchronization s = ( Synchronization ) synchronizations.get( i );
+				s.beforeCompletion();
+			}
+
+			status = Status.STATUS_COMMITTING;
+
+			if ( connection != null ) {
+				try {
+					connection.commit();
+					connection.close();
+				}
+				catch ( SQLException sqle ) {
+					status = Status.STATUS_UNKNOWN;
+					throw new SystemException();
+				}
+			}
+
+			status = Status.STATUS_COMMITTED;
+
+			for ( int i = 0; i < synchronizations.size(); i++ ) {
+				Synchronization s = ( Synchronization ) synchronizations.get( i );
+				s.afterCompletion( status );
+			}
+
+			//status = Status.STATUS_NO_TRANSACTION;
+			jtaTransactionManager.endCurrent( this );
+		}
+	}
+
+	public void rollback() throws IllegalStateException, SystemException {
+		status = Status.STATUS_ROLLEDBACK;
+
+		if ( connection != null ) {
+			try {
+				connection.rollback();
+				connection.close();
+			}
+			catch ( SQLException sqle ) {
+				status = Status.STATUS_UNKNOWN;
+				throw new SystemException();
+			}
+		}
+
+		for ( int i = 0; i < synchronizations.size(); i++ ) {
+			Synchronization s = ( Synchronization ) synchronizations.get( i );
+			s.afterCompletion( status );
+		}
+
+		//status = Status.STATUS_NO_TRANSACTION;
+		jtaTransactionManager.endCurrent( this );
+	}
+
+	public void setRollbackOnly() throws IllegalStateException, SystemException {
+		status = Status.STATUS_MARKED_ROLLBACK;
+	}
+
+	public void registerSynchronization(Synchronization synchronization)
+			throws RollbackException, IllegalStateException, SystemException {
+		// todo : find the spec-allowable statuses during which synch can be registered...
+		if ( synchronizations == null ) {
+			synchronizations = new LinkedList();
+		}
+		synchronizations.add( synchronization );
+	}
+
+	public void enlistConnection(Connection connection) {
+		if ( this.connection != null ) {
+			throw new IllegalStateException( "Connection already registered" );
+		}
+		this.connection = connection;
+	}
+
+	public Connection getEnlistedConnection() {
+		return connection;
+	}
+
+
+	public boolean enlistResource(XAResource xaResource)
+			throws RollbackException, IllegalStateException, SystemException {
+		return false;
+	}
+
+	public boolean delistResource(XAResource xaResource, int i) throws IllegalStateException, SystemException {
+		return false;
+	}
+}


Property changes on: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/SimpleJtaTransactionImpl.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision

Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/SimpleJtaTransactionManagerImpl.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/SimpleJtaTransactionManagerImpl.java	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/SimpleJtaTransactionManagerImpl.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -0,0 +1,110 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC 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 Middleware LLC.
+ *
+ * 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.jboss.test.hibernate.mocks;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+/**
+ * TransactionManager implementation specifically designed for use in test suite and simple usage
+ * scenarios.  For example, it assumes that there is only ever a single transaction active at a
+ * given time.
+ *
+ * @author Gavin King
+ * @author Steve Ebersole
+ */
+public class SimpleJtaTransactionManagerImpl implements TransactionManager {
+	private static final SimpleJtaTransactionManagerImpl INSTANCE = new SimpleJtaTransactionManagerImpl();
+
+	private SimpleJtaTransactionImpl currentTransaction;
+
+	public static SimpleJtaTransactionManagerImpl getInstance() {
+		return INSTANCE;
+	}
+
+	public int getStatus() throws SystemException {
+		return currentTransaction == null ? Status.STATUS_NO_TRANSACTION : currentTransaction.getStatus();
+	}
+
+	public Transaction getTransaction() throws SystemException {
+		return currentTransaction;
+	}
+
+	public SimpleJtaTransactionImpl getCurrentTransaction() {
+		return currentTransaction;
+	}
+
+	public void begin() throws NotSupportedException, SystemException {
+		currentTransaction = new SimpleJtaTransactionImpl( this );
+	}
+
+	public Transaction suspend() throws SystemException {
+		SimpleJtaTransactionImpl suspended = currentTransaction;
+		currentTransaction = null;
+		return suspended;
+	}
+
+	public void resume(Transaction transaction)
+			throws InvalidTransactionException, IllegalStateException, SystemException {
+		currentTransaction = ( SimpleJtaTransactionImpl ) transaction;
+	}
+
+	public void commit()
+			throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
+		if ( currentTransaction == null ) {
+			throw new IllegalStateException( "no current transaction to commit" );
+		}
+		currentTransaction.commit();
+	}
+
+	public void rollback() throws IllegalStateException, SecurityException, SystemException {
+		if ( currentTransaction == null ) {
+			throw new IllegalStateException( "no current transaction" );
+		}
+		currentTransaction.rollback();
+	}
+
+	public void setRollbackOnly() throws IllegalStateException, SystemException {
+		if ( currentTransaction == null ) {
+			throw new IllegalStateException( "no current transaction" );
+		}
+		currentTransaction.setRollbackOnly();
+	}
+
+	public void setTransactionTimeout(int i) throws SystemException {
+	}
+
+	void endCurrent(SimpleJtaTransactionImpl transaction) {
+		if ( transaction == currentTransaction ) {
+			currentTransaction = null;
+		}
+	}
+}


Property changes on: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/SimpleJtaTransactionManagerImpl.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision

Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/TransactionManagerLookupImpl.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/TransactionManagerLookupImpl.java	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/TransactionManagerLookupImpl.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -0,0 +1,50 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2007, Red Hat Middleware LLC 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 Middleware LLC.
+ *
+ * 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.jboss.test.hibernate.mocks;
+
+import java.util.Properties;
+import javax.transaction.TransactionManager;
+import javax.transaction.Transaction;
+
+import org.hibernate.transaction.TransactionManagerLookup;
+import org.hibernate.HibernateException;
+
+/**
+ * TransactionManagerLookupImpl implementation
+ *
+ * @author Steve Ebersole
+ */
+public class TransactionManagerLookupImpl implements TransactionManagerLookup {
+	public TransactionManager getTransactionManager(Properties props) throws HibernateException {
+		return SimpleJtaTransactionManagerImpl.getInstance();
+	}
+
+	public String getUserTransactionName() {
+		throw new UnsupportedOperationException( "jndi currently not implemented for these tests" );
+	}
+
+	public Object getTransactionIdentifier(Transaction transaction) {
+		return transaction;
+	}
+}


Property changes on: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/mocks/TransactionManagerLookupImpl.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision

Copied: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/test/HarWithStandardPropertiesUnitTestCase.java (from rev 96511, branches/Branch_5_x/testsuite/src/main/org/jboss/test/hibernate/test/HarWithStandardPropertiesUnitTestCase.java)
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/test/HarWithStandardPropertiesUnitTestCase.java	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/test/HarWithStandardPropertiesUnitTestCase.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.hibernate.test;
+
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.hibernate.timers.Timers;
+import org.jboss.test.hibernate.timers.TimersID;
+import org.jboss.test.hibernate.timers.interfaces.ITimers;
+import org.jboss.test.hibernate.timers.interfaces.ITimersHome;
+import org.jboss.test.hibernate.timers.interfaces.Info;
+import org.jboss.test.hibernate.timers.interfaces.Key;
+
+/**
+ * Test for JBAS-7411. Deploys a HAR whose -hibernate.xml uses standard 
+ * Hibernate property names instead of properties of the 
+ * org.jboss.hibernate.jmx.Hibernate class. Validates that it deploys and
+ * creates usable sessions.
+ * 
+ * This test borrows the classes from TimersUnitTestCase; just uses a different
+ * jboss-hibernate.xml file.
+ *
+ * @author Brian Stansberry
+ * @version $Revision: 81036 $
+ */
+public class HarWithStandardPropertiesUnitTestCase extends JBossTestCase
+{
+   public HarWithStandardPropertiesUnitTestCase(String name) throws Exception
+   {
+      super(name);
+   }
+
+   /**
+    Setup the test suite.
+    */
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(HarWithStandardPropertiesUnitTestCase.class, "hib-jbas7411.jar");
+   }
+
+   public void testCurrentSession() throws Throwable
+   {
+      InitialContext ctx = super.getInitialContext();
+      ITimersHome home = (ITimersHome) ctx.lookup("hib-timers/ITimersHome");
+      ITimers bean = null;
+
+      try
+      {
+         bean = home.create();
+
+         int initialCount = bean.listTimers().size();
+
+         TimersID id = new TimersID("testCurrentSession", "*:ejb=None");
+         Timers timer = new Timers(id);
+         Date now = new Date();
+         Long interval = new Long(5*1000);
+         Key key = new Key("key2", 123456789);
+         Info info = new Info(System.getProperties());
+         timer.setInitialDate(now);
+         timer.setInstancePK(serialize(key));
+         timer.setTimerInterval(interval);
+         timer.setInfo(serialize(info));
+
+         bean.persist(timer);
+         log.info("Timers created with id = " + id);
+
+         List timers = bean.listTimers();
+         assertNotNull(timers);
+         assertEquals("Incorrect result size", initialCount + 1, timers.size());
+
+         Timers found = null;
+         Iterator itr = timers.iterator();
+         while (itr.hasNext())
+         {
+            Timers t = (Timers) itr.next();
+            if (id.equals(t.getId()))
+            {
+               found = t;
+            }
+         }
+         assertNotNull("Saved timer found in list", found);
+         Date d = found.getInitialDate();
+         long t0 = (now.getTime() / 1000) * 1000;
+         long t1 = (d.getTime() / 1000) * 1000;
+         assertTrue("Timer.InitialDate("+t1+") == now("+t0+")", t0 == t1);
+         assertTrue("Timer.Id == id", found.getId().equals(id));
+         assertTrue("Timer.TimerInterval == interval", found.getTimerInterval().equals(interval));
+         Object tmp = deserialize(found.getInstancePK());
+         assertTrue("Timer.InstancePK == key", tmp.equals(key));
+         tmp = deserialize(found.getInfo());
+         log.info("Info: "+tmp);
+         assertTrue("Timer.Info == info", tmp.equals(info));
+         
+         // Scott forgot to remove the timer
+         bean.delete(timer);
+      }
+      finally
+      {
+         if (bean != null)
+         {
+            try
+            {
+               bean.remove();
+            }
+            catch (Throwable t)
+            {
+               // ignore
+            }
+         }
+      }
+   }
+
+}
\ No newline at end of file

Copied: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/test/HibernateConfigurationUnitTestCase.java (from rev 96511, branches/Branch_5_x/testsuite/src/main/org/jboss/test/hibernate/test/HibernateConfigurationUnitTestCase.java)
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/test/HibernateConfigurationUnitTestCase.java	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/hibernate/test/HibernateConfigurationUnitTestCase.java	2010-05-07 22:24:51 UTC (rev 104585)
@@ -0,0 +1,333 @@
+/**
+ * 
+ */
+package org.jboss.test.hibernate.test;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.cache.HashtableCacheProvider;
+import org.hibernate.cfg.Environment;
+import org.hibernate.cfg.Settings;
+import org.hibernate.dialect.HSQLDialect;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.transaction.JTATransactionFactory;
+import org.jboss.hibernate.deployers.metadata.BaseNamedElement;
+import org.jboss.hibernate.jmx.Hibernate;
+import org.jboss.test.hibernate.mocks.MockCacheProvider;
+import org.jboss.test.hibernate.mocks.MockInterceptor;
+import org.jboss.test.hibernate.mocks.MockListenerInjector;
+import org.jboss.test.hibernate.mocks.MockRegionFactory;
+import org.jboss.test.hibernate.mocks.TransactionManagerLookupImpl;
+
+/**
+ * A HibernateConfigurationUnitTestCase.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision: 1.1 $
+ */
+public class HibernateConfigurationUnitTestCase extends TestCase
+{
+   private static long testCount = System.currentTimeMillis();
+   
+   private File tempFile = null;
+   
+   private Hibernate testee;
+   
+   
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      tempFile = File.createTempFile(getClass().getSimpleName() + (testCount++), null);
+      tempFile.mkdirs();
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      try
+      {
+         try
+         {
+            super.tearDown();
+         }
+         finally
+         {
+            if (testee != null)
+            {
+               testee.stop();
+            }
+         }
+         
+      }
+      finally
+      {
+         if (tempFile != null && tempFile.exists())
+         {
+            if (!tempFile.delete())
+            {
+               tempFile.deleteOnExit();
+            }
+         }
+      }
+   }
+   
+   public void testDefaults() throws Throwable
+   {
+      testee = new TestableHibernate();
+
+      testee.setHarUrl(tempFile.toURI().toURL());
+      testee.setDialect(HSQLDialect.class.getName());
+      Set<BaseNamedElement> config = new HashSet<BaseNamedElement>();
+      config.add(createBaseNamedElement(Environment.TRANSACTION_MANAGER_STRATEGY, TransactionManagerLookupImpl.class.getName()));
+      config.add(createBaseNamedElement(Environment.USER_TRANSACTION, JTATransactionFactory.DEFAULT_USER_TRANSACTION_NAME));
+      testee.setConfigurationElements(config);
+      testee.start();
+      
+      SessionFactory factory = testee.getInstance();
+      assertTrue(factory instanceof SessionFactoryImplementor);
+      Settings settings = ((SessionFactoryImplementor) factory).getSettings();
+      assertTrue(settings.getTransactionFactory() instanceof JTATransactionFactory);
+      assertTrue(settings.isSecondLevelCacheEnabled());
+      
+      assertTrue(settings.isFlushBeforeCompletionEnabled());
+      assertTrue(settings.isAutoCloseSessionEnabled());
+      
+      Properties props = testee.getConfigurationProperties();
+      assertEquals(HashtableCacheProvider.class.getName(), props.getProperty(Environment.CACHE_PROVIDER));
+      assertEquals("after_statement", props.getProperty("hibernate.connection.release_mode"));
+      // Disabled, as use of JTA causes hibernate to ignore hibernate.connection.release_mode=after_statement
+      //assertEquals(ConnectionReleaseMode.AFTER_STATEMENT, settings.getConnectionReleaseMode());
+   }
+
+   public void testMBeanConfiguration() throws Throwable
+   {
+      testee = new TestableHibernate();
+      
+      // Non-Hibernate configs
+      testee.setHarUrl(tempFile.toURI().toURL());
+      testee.setScanForMappingsEnabled(true);
+      testee.setSessionFactoryInterceptor(MockInterceptor.class.getName());
+      testee.setListenerInjector(MockListenerInjector.class.getName());
+      
+      testee.setDialect(HSQLDialect.class.getName());
+//      testee.setDatasourceName("TestDS");
+      testee.setCacheProviderClass(MockCacheProvider.class.getName());
+      testee.setCacheRegionFactoryClass(MockRegionFactory.class.getName());
+      testee.setCacheRegionPrefix("aprefix");
+      testee.setMinimalPutsEnabled(true);
+      testee.setHbm2ddlAuto("bogus");
+      testee.setSecondLevelCacheEnabled(Boolean.TRUE);
+      testee.setQueryCacheEnabled(Boolean.TRUE);
+      testee.setUseStructuredCacheEntriesEnabled(Boolean.TRUE);
+      testee.setDefaultSchema("schema");
+      testee.setDefaultCatalog("catalog");
+      testee.setJdbcBatchSize(Integer.valueOf(8));
+      testee.setJdbcFetchSize(Integer.valueOf(9));
+      testee.setBatchVersionedDataEnabled(Boolean.TRUE);
+      testee.setMaxFetchDepth(Integer.valueOf(13));
+      testee.setJdbcScrollableResultSetEnabled(Boolean.TRUE);
+      testee.setSqlCommentsEnabled(Boolean.TRUE);
+      testee.setQuerySubstitutions("key=value");
+      testee.setShowSqlEnabled(Boolean.TRUE);
+      testee.setGetGeneratedKeysEnabled(Boolean.TRUE);
+      testee.setStatGenerationEnabled(Boolean.TRUE);
+      testee.setUsername("Brian");
+      testee.setPassword("Brian");
+      testee.setStreamsForBinaryEnabled(Boolean.TRUE);
+      testee.setReflectionOptimizationEnabled(Boolean.TRUE);
+      testee.setDeployedCacheJndiName("java:/test/Cache");
+      testee.setDeployedCacheManagerJndiName("java:/test/CacheManager");
+      
+      Set<BaseNamedElement> config = new HashSet<BaseNamedElement>();
+      config.add(createBaseNamedElement(Environment.TRANSACTION_MANAGER_STRATEGY, TransactionManagerLookupImpl.class.getName()));
+      config.add(createBaseNamedElement(Environment.USER_TRANSACTION, JTATransactionFactory.DEFAULT_USER_TRANSACTION_NAME));
+      config.add(createBaseNamedElement(org.hibernate.cache.jbc2.builder.MultiplexingCacheInstanceManager.ENTITY_CACHE_RESOURCE_PROP, "entities-test"));
+      testee.setConfigurationElements(config);
+      
+      testee.start();
+      validate(testee);
+   }
+   
+   public void testHibernatePropertyConfiguration() throws Throwable
+   {
+      testee = new TestableHibernate();
+      
+      Set<BaseNamedElement> config = new HashSet<BaseNamedElement>();
+      
+      config.add(createBaseNamedElement("harUrl", tempFile.toURI().toURL()));
+      config.add(createBaseNamedElement("scanForMappingsEnabled", Boolean.TRUE));
+      config.add(createBaseNamedElement("sessionFactoryInterceptor", MockInterceptor.class.getName()));
+      config.add(createBaseNamedElement("listenerInjector", MockListenerInjector.class.getName()));
+      
+      config.add(createBaseNamedElement(Environment.DIALECT, HSQLDialect.class.getName()));
+      config.add(createBaseNamedElement(Environment.TRANSACTION_MANAGER_STRATEGY, TransactionManagerLookupImpl.class.getName()));
+      config.add(createBaseNamedElement(Environment.USER_TRANSACTION, JTATransactionFactory.DEFAULT_USER_TRANSACTION_NAME));
+      
+//      config.add(createBaseNamedElement(Environment.DATASOURCE, "TestDS"));
+      config.add(createBaseNamedElement(Environment.CACHE_PROVIDER, MockCacheProvider.class.getName()));
+      config.add(createBaseNamedElement(Environment.CACHE_REGION_FACTORY, MockRegionFactory.class.getName()));
+      config.add(createBaseNamedElement(Environment.CACHE_REGION_PREFIX, "aprefix"));
+      config.add(createBaseNamedElement(Environment.USE_MINIMAL_PUTS, Boolean.TRUE));
+      config.add(createBaseNamedElement(Environment.HBM2DDL_AUTO, "bogus"));
+      config.add(createBaseNamedElement(Environment.DEFAULT_SCHEMA, "schema"));
+      config.add(createBaseNamedElement(Environment.DEFAULT_CATALOG, "catalog"));
+      config.add(createBaseNamedElement(Environment.USE_SECOND_LEVEL_CACHE, Boolean.TRUE));
+      config.add(createBaseNamedElement(Environment.USE_QUERY_CACHE, Boolean.TRUE));
+      config.add(createBaseNamedElement(Environment.USE_STRUCTURED_CACHE, Boolean.TRUE));
+      config.add(createBaseNamedElement(Environment.STATEMENT_BATCH_SIZE, Integer.valueOf(8)));
+      config.add(createBaseNamedElement(Environment.STATEMENT_FETCH_SIZE, Integer.valueOf(9)));
+      config.add(createBaseNamedElement(Environment.BATCH_VERSIONED_DATA, Boolean.TRUE));
+      config.add(createBaseNamedElement(Environment.MAX_FETCH_DEPTH, Integer.valueOf(13)));
+      config.add(createBaseNamedElement(Environment.USE_SCROLLABLE_RESULTSET, Boolean.TRUE));
+      config.add(createBaseNamedElement(Environment.USE_SQL_COMMENTS, Boolean.TRUE));
+      config.add(createBaseNamedElement(Environment.QUERY_SUBSTITUTIONS, "key=value"));
+      config.add(createBaseNamedElement(Environment.SHOW_SQL, Boolean.TRUE));
+      config.add(createBaseNamedElement(Environment.USE_GET_GENERATED_KEYS, Boolean.TRUE));
+      config.add(createBaseNamedElement(Environment.GENERATE_STATISTICS, Boolean.TRUE));
+      config.add(createBaseNamedElement(Environment.USER, "Brian"));
+      config.add(createBaseNamedElement(Environment.PASS, "Brian"));
+      config.add(createBaseNamedElement(Environment.USE_STREAMS_FOR_BINARY, Boolean.TRUE));
+      config.add(createBaseNamedElement(Environment.USE_REFLECTION_OPTIMIZER, Boolean.TRUE));
+      config.add(createBaseNamedElement(org.hibernate.cache.jbc2.builder.JndiSharedCacheInstanceManager.CACHE_RESOURCE_PROP, "java:/test/Cache"));
+      config.add(createBaseNamedElement(org.hibernate.cache.jbc2.builder.JndiMultiplexingCacheInstanceManager.CACHE_FACTORY_RESOURCE_PROP, "java:/test/CacheManager"));
+      config.add(createBaseNamedElement(org.hibernate.cache.jbc2.builder.MultiplexingCacheInstanceManager.ENTITY_CACHE_RESOURCE_PROP, "entities-test"));
+      
+      testee.setConfigurationElements(config);
+      testee.start();
+      validate(testee); 
+   }
+   
+   public void testLegacyPropertyNames() throws Throwable
+   {
+      testee = new TestableHibernate();
+      
+      Set<BaseNamedElement> config = new HashSet<BaseNamedElement>();
+      
+      config.add(createBaseNamedElement("harUrl", tempFile.toURI().toURL()));
+      config.add(createBaseNamedElement("scanForMappingsEnabled", Boolean.TRUE));
+      config.add(createBaseNamedElement("sessionFactoryInterceptor", MockInterceptor.class.getName()));
+      config.add(createBaseNamedElement("listenerInjector", MockListenerInjector.class.getName()));
+      
+      config.add(createBaseNamedElement("dialect", HSQLDialect.class.getName()));
+      
+      config.add(createBaseNamedElement(Environment.TRANSACTION_MANAGER_STRATEGY, TransactionManagerLookupImpl.class.getName()));
+      config.add(createBaseNamedElement(Environment.USER_TRANSACTION, JTATransactionFactory.DEFAULT_USER_TRANSACTION_NAME));
+      
+//      config.add(createBaseNamedElement("datasourceName", "TestDS"));
+      config.add(createBaseNamedElement("cacheProviderClass", MockCacheProvider.class.getName()));
+      config.add(createBaseNamedElement("cacheRegionFactoryClass", MockRegionFactory.class.getName()));
+      config.add(createBaseNamedElement("cacheRegionPrefix", "aprefix"));
+      config.add(createBaseNamedElement("minimalPutsEnabled", Boolean.TRUE));
+      config.add(createBaseNamedElement("hbm2ddlAuto", "bogus"));
+      config.add(createBaseNamedElement("defaultSchema", "schema"));
+      config.add(createBaseNamedElement("defaultCatalog", "catalog"));
+      config.add(createBaseNamedElement("secondLevelCacheEnabled", Boolean.TRUE));
+      config.add(createBaseNamedElement("queryCacheEnabled", Boolean.TRUE));
+      config.add(createBaseNamedElement("useStructuredCacheEntriesEnabled", Boolean.TRUE));
+      config.add(createBaseNamedElement("jdbcBatchSize", Integer.valueOf(8)));
+      config.add(createBaseNamedElement("jdbcFetchSize", Integer.valueOf(9)));
+      config.add(createBaseNamedElement("batchVersionedDataEnabled", Boolean.TRUE));
+      config.add(createBaseNamedElement("maxFetchDepth", Integer.valueOf(13)));
+      config.add(createBaseNamedElement("jdbcScrollableResultSetEnabled", Boolean.TRUE));
+      config.add(createBaseNamedElement("sqlCommentsEnabled", Boolean.TRUE));
+      config.add(createBaseNamedElement("querySubstitutions", "key=value"));
+      config.add(createBaseNamedElement("showSqlEnabled", Boolean.TRUE));
+      config.add(createBaseNamedElement("getGeneratedKeysEnabled", Boolean.TRUE));
+      config.add(createBaseNamedElement("statGenerationEnabled", Boolean.TRUE));
+      config.add(createBaseNamedElement("username", "Brian"));
+      config.add(createBaseNamedElement("password", "Brian"));
+      config.add(createBaseNamedElement("streamsForBinaryEnabled", Boolean.TRUE));
+      config.add(createBaseNamedElement("reflectionOptimizationEnabled", Boolean.TRUE));
+      config.add(createBaseNamedElement("deployedCacheJndiName", "java:/test/Cache"));
+      config.add(createBaseNamedElement("deployedCacheManagerJndiName", "java:/test/CacheManager"));
+      config.add(createBaseNamedElement(org.hibernate.cache.jbc2.builder.MultiplexingCacheInstanceManager.ENTITY_CACHE_RESOURCE_PROP, "entities-test"));
+      
+      testee.setConfigurationElements(config);
+      testee.start();
+      validate(testee);
+      
+   }
+   
+   private void validate(Hibernate testee) throws Exception
+   {
+      // Validate getter values on Hibernate object
+      assertEquals(TestableHibernate.class.getSimpleName() + testCount, testee.getSessionFactoryName());
+      assertEquals(tempFile.toURI().toURL(), testee.getHarUrl());
+      assertTrue(testee.isScanForMappingsEnabled());
+      assertEquals(MockInterceptor.class.getName(), testee.getSessionFactoryInterceptor());
+      assertEquals(MockListenerInjector.class.getName(), testee.getListenerInjector());
+      
+      // Where we can, validate stuff exposed by hibernate Settings
+      SessionFactory factory = testee.getInstance();
+      assertTrue(factory instanceof SessionFactoryImplementor);
+      Settings settings = ((SessionFactoryImplementor) factory).getSettings();
+      
+//      assertEquals(TestableHibernate.class.getSimpleName() + testCount, settings.getSessionFactoryName());
+      assertEquals(HSQLDialect.class.getName(), testee.getDialect());
+      assertTrue(settings.getDialect() instanceof HSQLDialect);
+      assertTrue(settings.getTransactionFactory() instanceof JTATransactionFactory);
+      assertTrue(settings.getTransactionManagerLookup() instanceof TransactionManagerLookupImpl);
+      assertTrue(settings.getRegionFactory() instanceof MockRegionFactory);
+      assertEquals("aprefix", settings.getCacheRegionPrefix());
+      assertTrue(settings.isMinimalPutsEnabled());
+      assertTrue(settings.isSecondLevelCacheEnabled());
+      assertTrue(settings.isQueryCacheEnabled());
+      assertTrue(settings.isStructuredCacheEntriesEnabled());
+      assertEquals("schema", settings.getDefaultSchemaName());
+      assertEquals("catalog", settings.getDefaultCatalogName());
+      assertEquals(Integer.valueOf(9), settings.getJdbcFetchSize());
+      assertTrue(settings.isJdbcBatchVersionedData());
+      assertEquals(Integer.valueOf(13), settings.getMaximumFetchDepth());
+      assertTrue(settings.isScrollableResultSetsEnabled());
+      assertTrue(settings.isCommentsEnabled());
+      @SuppressWarnings("unchecked")
+      Map substitutions = settings.getQuerySubstitutions();
+      assertNotNull(substitutions);
+      assertEquals(1, substitutions.size());
+      assertEquals("value", substitutions.get("key"));
+      assertTrue(settings.getSqlStatementLogger().isLogToStdout());
+      assertTrue(settings.isGetGeneratedKeysEnabled());
+      assertTrue(settings.isStatisticsEnabled());
+      
+      // For stuff not available via Settings, second best is to check the properties exposed by Hibernate object
+      Properties props = testee.getConfigurationProperties();
+      assertEquals(JTATransactionFactory.DEFAULT_USER_TRANSACTION_NAME, props.getProperty(Environment.USER_TRANSACTION));
+      assertEquals(MockCacheProvider.class.getName(), props.getProperty(Environment.CACHE_PROVIDER));
+      assertEquals("bogus", props.getProperty(Environment.HBM2DDL_AUTO));
+      assertEquals("8", props.getProperty(Environment.STATEMENT_BATCH_SIZE));
+      assertEquals("Brian", props.getProperty(Environment.USER));
+      assertEquals("Brian", props.getProperty(Environment.PASS));
+      assertEquals("true", props.getProperty(Environment.USE_STREAMS_FOR_BINARY));
+      assertEquals("true", props.getProperty(Environment.USE_REFLECTION_OPTIMIZER));
+      assertEquals("java:/test/Cache", props.getProperty(org.hibernate.cache.jbc2.builder.JndiSharedCacheInstanceManager.CACHE_RESOURCE_PROP));
+      assertEquals("java:/test/CacheManager", props.getProperty(org.hibernate.cache.jbc2.builder.JndiMultiplexingCacheInstanceManager.CACHE_FACTORY_RESOURCE_PROP));
+      assertEquals("entities-test", props.getProperty(org.hibernate.cache.jbc2.builder.MultiplexingCacheInstanceManager.ENTITY_CACHE_RESOURCE_PROP));
+   }
+   
+   private static BaseNamedElement createBaseNamedElement(String name, Object value)
+   {
+      BaseNamedElement element = new BaseNamedElement();
+      element.setName(name);
+      element.setValue(value);
+      return element;
+   }
+   
+   private static class TestableHibernate extends Hibernate
+   {
+      public TestableHibernate()
+      {
+         super(null, false);
+         
+         setSessionFactoryName(getClass().getSimpleName() + testCount);
+      }
+   }
+}

Copied: branches/JBPAPP_5_1/testsuite/src/resources/hibernate/jbas7411 (from rev 96511, branches/Branch_5_x/testsuite/src/resources/hibernate/jbas7411)

Deleted: branches/JBPAPP_5_1/testsuite/src/resources/hibernate/jbas7411/Timers.hbm.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/hibernate/jbas7411/Timers.hbm.xml	2009-11-18 22:53:20 UTC (rev 96511)
+++ branches/JBPAPP_5_1/testsuite/src/resources/hibernate/jbas7411/Timers.hbm.xml	2010-05-07 22:24:51 UTC (rev 104585)
@@ -1,34 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<hibernate-mapping package="org.jboss.test.hibernate.timers">
-<!--
- $Id: Timers.hbm.xml 35847 2005-09-10 23:36:12Z starksm $
--->
-    <class name="Timers"
-           table="TIMERS" schema="PUBLIC">
-        
-        <cache usage="transactional"/>
-        
-        <composite-id name="id" class="org.jboss.test.hibernate.timers.TimersID">
-            <key-property name="timerID" type="string">
-                <column name="TIMERID" length="80" />
-            </key-property>
-            <key-property name="targetID" type="string">
-                <column name="TARGETID" length="80" />
-            </key-property>
-        </composite-id>
-        <property name="initialDate" type="timestamp">
-            <column name="INITIALDATE" length="6" not-null="true" />
-        </property>
-        <property name="timerInterval" type="long">
-            <column name="TIMERINTERVAL" />
-        </property>
-        <property name="instancePK" type="binary">
-            <column name="INSTANCEPK" />
-        </property>
-        <property name="info" type="binary">
-            <column name="INFO" />
-        </property>
-    </class>
-</hibernate-mapping>

Copied: branches/JBPAPP_5_1/testsuite/src/resources/hibernate/jbas7411/Timers.hbm.xml (from rev 96511, branches/Branch_5_x/testsuite/src/resources/hibernate/jbas7411/Timers.hbm.xml)
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/hibernate/jbas7411/Timers.hbm.xml	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/resources/hibernate/jbas7411/Timers.hbm.xml	2010-05-07 22:24:51 UTC (rev 104585)
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping package="org.jboss.test.hibernate.timers">
+<!--
+ $Id: Timers.hbm.xml 35847 2005-09-10 23:36:12Z starksm $
+-->
+    <class name="Timers"
+           table="TIMERS" schema="PUBLIC">
+        
+        <cache usage="transactional"/>
+        
+        <composite-id name="id" class="org.jboss.test.hibernate.timers.TimersID">
+            <key-property name="timerID" type="string">
+                <column name="TIMERID" length="80" />
+            </key-property>
+            <key-property name="targetID" type="string">
+                <column name="TARGETID" length="80" />
+            </key-property>
+        </composite-id>
+        <property name="initialDate" type="timestamp">
+            <column name="INITIALDATE" length="6" not-null="true" />
+        </property>
+        <property name="timerInterval" type="long">
+            <column name="TIMERINTERVAL" />
+        </property>
+        <property name="instancePK" type="binary">
+            <column name="INSTANCEPK" />
+        </property>
+        <property name="info" type="binary">
+            <column name="INFO" />
+        </property>
+    </class>
+</hibernate-mapping>

Deleted: branches/JBPAPP_5_1/testsuite/src/resources/hibernate/jbas7411/jboss-hibernate.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/hibernate/jbas7411/jboss-hibernate.xml	2009-11-18 22:53:20 UTC (rev 96511)
+++ branches/JBPAPP_5_1/testsuite/src/resources/hibernate/jbas7411/jboss-hibernate.xml	2010-05-07 22:24:51 UTC (rev 104585)
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<hibernate-configuration xmlns="urn:jboss:hibernate-deployer:1.0">
-
-   <session-factory name="java:/hib-timers/SessionFactory" bean="jboss.test.har:service=Hibernate,testcase=HarWithStandardPropertiesUnitTestCase">
-      <property name="hibernate.connection.datasource">java:/DefaultDS</property>
-      <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
-      <!-- no such class
-      <property name="sessionFactoryInterceptor">org.jboss.test.hibernate.SimpleInterceptor</property>
-      -->
-      <property name="hibernate.hbm2ddl.auto">create</property>
-      
-      <!-- The test doesn't actually cache anything, but let's set some properties to check
-           that they work -->
-      <property name="hibernate.cache.use_second_level_cache">true</property>
-      <property name="hibernate.cache.region_prefix">HarWithStandardProperties</property>
-      <property name="hibernate.cache.region.factory_class">org.hibernate.cache.jbc2.JndiMultiplexedJBossCacheRegionFactory</property>
-      <property name="hibernate.cache.region.jbc2.cachefactory">java:/CacheManager</property>
-      <property name="hibernate.cache.region.jbc2.cfg.entity">mvcc-shared</property>
-      
-      <depends>jboss:service=Naming</depends>
-      <depends>jboss:service=TransactionManager</depends>
-   </session-factory>
-
-</hibernate-configuration>

Copied: branches/JBPAPP_5_1/testsuite/src/resources/hibernate/jbas7411/jboss-hibernate.xml (from rev 96511, branches/Branch_5_x/testsuite/src/resources/hibernate/jbas7411/jboss-hibernate.xml)
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/hibernate/jbas7411/jboss-hibernate.xml	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/resources/hibernate/jbas7411/jboss-hibernate.xml	2010-05-07 22:24:51 UTC (rev 104585)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<hibernate-configuration xmlns="urn:jboss:hibernate-deployer:1.0">
+
+   <session-factory name="java:/hib-timers/SessionFactory" bean="jboss.test.har:service=Hibernate,testcase=HarWithStandardPropertiesUnitTestCase">
+      <property name="hibernate.connection.datasource">java:/DefaultDS</property>
+      <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+      <!-- no such class
+      <property name="sessionFactoryInterceptor">org.jboss.test.hibernate.SimpleInterceptor</property>
+      -->
+      <property name="hibernate.hbm2ddl.auto">create</property>
+      
+      <!-- The test doesn't actually cache anything, but let's set some properties to check
+           that they work -->
+      <property name="hibernate.cache.use_second_level_cache">true</property>
+      <property name="hibernate.cache.region_prefix">HarWithStandardProperties</property>
+      <property name="hibernate.cache.region.factory_class">org.hibernate.cache.jbc2.JndiMultiplexedJBossCacheRegionFactory</property>
+      <property name="hibernate.cache.region.jbc2.cachefactory">java:/CacheManager</property>
+      <property name="hibernate.cache.region.jbc2.cfg.entity">mvcc-shared</property>
+      
+      <depends>jboss:service=Naming</depends>
+      <depends>jboss:service=TransactionManager</depends>
+   </session-factory>
+
+</hibernate-configuration>




More information about the jboss-cvs-commits mailing list