diff --git a/core/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java b/core/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java index e318381634..2be85ef991 100644 --- a/core/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java +++ b/core/src/main/java/org/hibernate/cfg/AnnotationConfiguration.java @@ -55,6 +55,7 @@ import org.hibernate.mapping.IdGenerator; import org.hibernate.mapping.Join; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Table; +import org.hibernate.persister.PersisterClassProvider; import org.hibernate.util.CollectionHelper; /** @@ -267,6 +268,12 @@ public class AnnotationConfiguration extends Configuration { return this; } + @Override + public AnnotationConfiguration setPersisterClassProvider(PersisterClassProvider persisterClassProvider) { + super.setPersisterClassProvider( persisterClassProvider ); + return this; + } + @Deprecated protected class ExtendedMappingsImpl extends MappingsImpl implements ExtendedMappings { } diff --git a/core/src/main/java/org/hibernate/cfg/Configuration.java b/core/src/main/java/org/hibernate/cfg/Configuration.java index 723c0c1a07..51f7232e44 100644 --- a/core/src/main/java/org/hibernate/cfg/Configuration.java +++ b/core/src/main/java/org/hibernate/cfg/Configuration.java @@ -148,6 +148,7 @@ import org.hibernate.mapping.SimpleValue; import org.hibernate.mapping.Table; import org.hibernate.mapping.TypeDef; import org.hibernate.mapping.UniqueKey; +import org.hibernate.persister.PersisterClassProvider; import org.hibernate.proxy.EntityNotFoundDelegate; import org.hibernate.secure.JACCConfiguration; import org.hibernate.tool.hbm2ddl.DatabaseMetadata; @@ -258,6 +259,7 @@ public class Configuration implements Serializable { protected transient XMLHelper xmlHelper; protected NamingStrategy namingStrategy; + private PersisterClassProvider persisterClassProvider; private SessionFactoryObserver sessionFactoryObserver; private EventListeners eventListeners; @@ -355,6 +357,7 @@ public class Configuration implements Serializable { propertyRefResolver = new HashMap(); caches = new ArrayList(); namingStrategy = EJB3NamingStrategy.INSTANCE; + persisterClassProvider = null; setEntityResolver( new EJB3DTDEntityResolver() ); anyMetaDefs = new HashMap(); propertiesAnnotatedWithMapsId = new HashMap>(); @@ -2860,6 +2863,26 @@ public class Configuration implements Serializable { return this; } + public PersisterClassProvider getPersisterClassProvider() { + return persisterClassProvider; + } + + /** + * Defines a custom persister class provider. + * + * The persister class is chosen according to the following rules in decreasing priority: + * - the persister class defined explicitly via annotation or XML + * - the persister class returned by the PersisterClassProvider implementation (if not null) + * - the default provider as chosen by Hibernate Core (best choice most of the time) + * + * + * @param persisterClassProvider implementation + */ + public Configuration setPersisterClassProvider(PersisterClassProvider persisterClassProvider) { + this.persisterClassProvider = persisterClassProvider; + return this; + } + /** * Retrieve the IdentifierGeneratorFactory in effect for this configuration. * @@ -3092,6 +3115,14 @@ public class Configuration implements Serializable { Configuration.this.namingStrategy = namingStrategy; } + public PersisterClassProvider getPersisterClassProvider() { + return persisterClassProvider; + } + + public void setPersisterClassProvider(PersisterClassProvider persisterClassProvider) { + Configuration.this.persisterClassProvider = persisterClassProvider; + } + public TypeResolver getTypeResolver() { return typeResolver; } diff --git a/core/src/main/java/org/hibernate/cfg/Mappings.java b/core/src/main/java/org/hibernate/cfg/Mappings.java index 3e3bb128dd..7886b3f777 100644 --- a/core/src/main/java/org/hibernate/cfg/Mappings.java +++ b/core/src/main/java/org/hibernate/cfg/Mappings.java @@ -51,6 +51,7 @@ import org.hibernate.mapping.TypeDef; import org.hibernate.mapping.AuxiliaryDatabaseObject; import org.hibernate.mapping.Column; import org.hibernate.mapping.FetchProfile; +import org.hibernate.persister.PersisterClassProvider; import org.hibernate.type.TypeResolver; /** @@ -89,6 +90,16 @@ public interface Mappings { */ public void setNamingStrategy(NamingStrategy namingStrategy); + /** + * Get the current persister class provider implementation + */ + public PersisterClassProvider getPersisterClassProvider(); + + /** + * Set the current persister class provider implementation + */ + public void setPersisterClassProvider(PersisterClassProvider persisterClassProvider); + /** * Returns the currently bound default schema name. *