HHH-4664 - Implement EntityManagerFactory#getProperties()

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18712 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2010-02-07 19:27:19 +00:00
parent 71127daf09
commit 7cb83cac95
3 changed files with 32 additions and 4 deletions

View File

@ -25,6 +25,7 @@
package org.hibernate.engine; package org.hibernate.engine;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.sql.Connection; import java.sql.Connection;
@ -62,6 +63,13 @@ import org.hibernate.type.Type;
*/ */
public interface SessionFactoryImplementor extends Mapping, SessionFactory { 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 * Get the persister for the named entity
* *

View File

@ -467,6 +467,10 @@ public final class SessionFactoryImpl implements SessionFactory, SessionFactoryI
this.observer.sessionFactoryCreated( this ); this.observer.sessionFactoryCreated( this );
} }
public Properties getProperties() {
return properties;
}
public IdentifierGeneratorFactory getIdentifierGeneratorFactory() { public IdentifierGeneratorFactory getIdentifierGeneratorFactory() {
return null; return null;
} }

View File

@ -21,7 +21,10 @@
*/ */
package org.hibernate.ejb; package org.hibernate.ejb;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.Iterator; import java.util.Iterator;
import java.io.Serializable; import java.io.Serializable;
@ -61,7 +64,9 @@ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory {
private final CriteriaBuilderImpl criteriaBuilder; private final CriteriaBuilderImpl criteriaBuilder;
private final Metamodel metamodel; private final Metamodel metamodel;
private final HibernatePersistenceUnitUtil util; private final HibernatePersistenceUnitUtil util;
private final Map<String,Object> properties;
@SuppressWarnings( "unchecked" )
public EntityManagerFactoryImpl( public EntityManagerFactoryImpl(
SessionFactory sessionFactory, SessionFactory sessionFactory,
PersistenceUnitTransactionType transactionType, PersistenceUnitTransactionType transactionType,
@ -72,7 +77,6 @@ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory {
this.transactionType = transactionType; this.transactionType = transactionType;
this.discardOnClose = discardOnClose; this.discardOnClose = discardOnClose;
this.sessionInterceptorClass = sessionInterceptorClass; this.sessionInterceptorClass = sessionInterceptorClass;
@SuppressWarnings( "unchecked" )
final Iterator<PersistentClass> classes = cfg.getClassMappings(); final Iterator<PersistentClass> classes = cfg.getClassMappings();
//a safe guard till we are confident that metamodel is wll tested //a safe guard till we are confident that metamodel is wll tested
if ( !"disabled".equalsIgnoreCase( cfg.getProperty( "hibernate.ejb.metamodel.generation" ) ) ) { if ( !"disabled".equalsIgnoreCase( cfg.getProperty( "hibernate.ejb.metamodel.generation" ) ) ) {
@ -83,6 +87,19 @@ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory {
} }
this.criteriaBuilder = new CriteriaBuilderImpl( this ); this.criteriaBuilder = new CriteriaBuilderImpl( this );
this.util = new HibernatePersistenceUnitUtil( this ); this.util = new HibernatePersistenceUnitUtil( this );
HashMap<String,Object> props = new HashMap<String, Object>();
addAll( props, ( (SessionFactoryImplementor) sessionFactory ).getProperties() );
addAll( props, cfg.getProperties() );
this.properties = Collections.unmodifiableMap( props );
}
private static void addAll(HashMap<String, Object> 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() { public EntityManager createEntityManager() {
@ -102,7 +119,7 @@ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory {
} }
public Metamodel getMetamodel() { public Metamodel getMetamodel() {
return metamodel; //To change body of implemented methods use File | Settings | File Templates. return metamodel;
} }
public void close() { public void close() {
@ -110,8 +127,7 @@ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory {
} }
public Map<String, Object> getProperties() { public Map<String, Object> getProperties() {
//FIXME return properties;
return null; //To change body of implemented methods use File | Settings | File Templates.
} }
public Cache getCache() { public Cache getCache() {