diff --git a/core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java b/core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java index 5b779226f0..69d3003474 100644 --- a/core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java +++ b/core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java @@ -25,6 +25,7 @@ package org.hibernate.engine; import java.util.Map; +import java.util.Properties; import java.util.Set; import java.sql.Connection; @@ -62,6 +63,13 @@ import org.hibernate.type.Type; */ public interface SessionFactoryImplementor extends Mapping, SessionFactory { + /** + * Get a copy of the Properties used to configure this session factory. + * + * @return The properties. + */ + public Properties getProperties(); + /** * Get the persister for the named entity * diff --git a/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java b/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java index 81cf213d77..dc2dfcb973 100644 --- a/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java +++ b/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java @@ -467,6 +467,10 @@ public final class SessionFactoryImpl implements SessionFactory, SessionFactoryI this.observer.sessionFactoryCreated( this ); } + public Properties getProperties() { + return properties; + } + public IdentifierGeneratorFactory getIdentifierGeneratorFactory() { return null; } diff --git a/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java b/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java index 6bc40acc3d..fe468931d7 100755 --- a/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java +++ b/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java @@ -21,7 +21,10 @@ */ package org.hibernate.ejb; +import java.util.Collections; +import java.util.HashMap; import java.util.Map; +import java.util.Properties; import java.util.Set; import java.util.Iterator; import java.io.Serializable; @@ -61,7 +64,9 @@ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory { private final CriteriaBuilderImpl criteriaBuilder; private final Metamodel metamodel; private final HibernatePersistenceUnitUtil util; + private final Map properties; + @SuppressWarnings( "unchecked" ) public EntityManagerFactoryImpl( SessionFactory sessionFactory, PersistenceUnitTransactionType transactionType, @@ -72,7 +77,6 @@ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory { this.transactionType = transactionType; this.discardOnClose = discardOnClose; this.sessionInterceptorClass = sessionInterceptorClass; - @SuppressWarnings( "unchecked" ) final Iterator classes = cfg.getClassMappings(); //a safe guard till we are confident that metamodel is wll tested if ( !"disabled".equalsIgnoreCase( cfg.getProperty( "hibernate.ejb.metamodel.generation" ) ) ) { @@ -83,6 +87,19 @@ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory { } this.criteriaBuilder = new CriteriaBuilderImpl( this ); this.util = new HibernatePersistenceUnitUtil( this ); + + HashMap props = new HashMap(); + addAll( props, ( (SessionFactoryImplementor) sessionFactory ).getProperties() ); + addAll( props, cfg.getProperties() ); + this.properties = Collections.unmodifiableMap( props ); + } + + private static void addAll(HashMap propertyMap, Properties properties) { + for ( Map.Entry entry : properties.entrySet() ) { + if ( String.class.isInstance( entry.getKey() ) ) { + propertyMap.put( (String)entry.getKey(), entry.getValue() ); + } + } } public EntityManager createEntityManager() { @@ -102,7 +119,7 @@ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory { } public Metamodel getMetamodel() { - return metamodel; //To change body of implemented methods use File | Settings | File Templates. + return metamodel; } public void close() { @@ -110,8 +127,7 @@ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory { } public Map getProperties() { - //FIXME - return null; //To change body of implemented methods use File | Settings | File Templates. + return properties; } public Cache getCache() {