HHH-5916 Expose PersisterClassProvider configuration

This commit is contained in:
Emmanuel Bernard 2011-02-14 13:54:48 +01:00 committed by JPAV
parent 337fd30256
commit 55eb37ed52
3 changed files with 55 additions and 2 deletions

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
@ -30,6 +31,7 @@ import org.dom4j.Document;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.Interceptor; import org.hibernate.Interceptor;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.persister.PersisterClassProvider;
/** /**
* Similar to the {@link Configuration} object but handles EJB3 and Hibernate * Similar to the {@link Configuration} object but handles EJB3 and Hibernate
@ -236,6 +238,12 @@ public class AnnotationConfiguration extends Configuration {
return this; return this;
} }
@Override
public AnnotationConfiguration setPersisterClassProvider(PersisterClassProvider persisterClassProvider) {
super.setPersisterClassProvider( persisterClassProvider );
return this;
}
@Deprecated @Deprecated
protected class ExtendedMappingsImpl extends MappingsImpl implements ExtendedMappings { protected class ExtendedMappingsImpl extends MappingsImpl implements ExtendedMappings {
} }

View File

@ -144,6 +144,7 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.mapping.TypeDef; import org.hibernate.mapping.TypeDef;
import org.hibernate.mapping.UniqueKey; import org.hibernate.mapping.UniqueKey;
import org.hibernate.persister.PersisterClassProvider;
import org.hibernate.proxy.EntityNotFoundDelegate; import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.secure.JACCConfiguration; import org.hibernate.secure.JACCConfiguration;
import org.hibernate.service.spi.ServiceRegistry; import org.hibernate.service.spi.ServiceRegistry;
@ -258,6 +259,7 @@ public class Configuration implements Serializable {
protected transient XMLHelper xmlHelper; protected transient XMLHelper xmlHelper;
protected NamingStrategy namingStrategy; protected NamingStrategy namingStrategy;
private PersisterClassProvider persisterClassProvider;
private SessionFactoryObserver sessionFactoryObserver; private SessionFactoryObserver sessionFactoryObserver;
private EventListeners eventListeners; private EventListeners eventListeners;
@ -355,6 +357,7 @@ public class Configuration implements Serializable {
propertyRefResolver = new HashMap<String, String>(); propertyRefResolver = new HashMap<String, String>();
caches = new ArrayList<CacheHolder>(); caches = new ArrayList<CacheHolder>();
namingStrategy = EJB3NamingStrategy.INSTANCE; namingStrategy = EJB3NamingStrategy.INSTANCE;
persisterClassProvider = null;
setEntityResolver( new EJB3DTDEntityResolver() ); setEntityResolver( new EJB3DTDEntityResolver() );
anyMetaDefs = new HashMap<String, AnyMetaDef>(); anyMetaDefs = new HashMap<String, AnyMetaDef>();
propertiesAnnotatedWithMapsId = new HashMap<XClass, Map<String, PropertyData>>(); propertiesAnnotatedWithMapsId = new HashMap<XClass, Map<String, PropertyData>>();
@ -2844,6 +2847,26 @@ public class Configuration implements Serializable {
return this; 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. * Retrieve the IdentifierGeneratorFactory in effect for this configuration.
* *
@ -3076,6 +3099,14 @@ public class Configuration implements Serializable {
Configuration.this.namingStrategy = namingStrategy; Configuration.this.namingStrategy = namingStrategy;
} }
public PersisterClassProvider getPersisterClassProvider() {
return persisterClassProvider;
}
public void setPersisterClassProvider(PersisterClassProvider persisterClassProvider) {
Configuration.this.persisterClassProvider = persisterClassProvider;
}
public TypeResolver getTypeResolver() { public TypeResolver getTypeResolver() {
return typeResolver; return typeResolver;
} }

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.cfg; package org.hibernate.cfg;
import java.io.Serializable; import java.io.Serializable;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -49,6 +50,7 @@ import org.hibernate.mapping.MetadataSource;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.mapping.TypeDef; import org.hibernate.mapping.TypeDef;
import org.hibernate.persister.PersisterClassProvider;
import org.hibernate.type.TypeResolver; import org.hibernate.type.TypeResolver;
/** /**
@ -87,6 +89,16 @@ public interface Mappings {
*/ */
public void setNamingStrategy(NamingStrategy namingStrategy); 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. * Returns the currently bound default schema name.
* *
@ -686,6 +698,7 @@ public interface Mappings {
/** /**
* @deprecated Use {@link #getUniqueConstraintHoldersByTable} instead * @deprecated Use {@link #getUniqueConstraintHoldersByTable} instead
*/ */
@Deprecated
@SuppressWarnings({ "JavaDoc" }) @SuppressWarnings({ "JavaDoc" })
public Map<Table, List<String[]>> getTableUniqueConstraints(); public Map<Table, List<String[]>> getTableUniqueConstraints();
@ -694,6 +707,7 @@ public interface Mappings {
/** /**
* @deprecated Use {@link #addUniqueConstraintHolders} instead * @deprecated Use {@link #addUniqueConstraintHolders} instead
*/ */
@Deprecated
@SuppressWarnings({ "JavaDoc" }) @SuppressWarnings({ "JavaDoc" })
public void addUniqueConstraints(Table table, List uniqueConstraints); public void addUniqueConstraints(Table table, List uniqueConstraints);