HHH-6281 - Basic HbmBinder cleanup
This commit is contained in:
parent
b84ec25b63
commit
e68f4fb085
|
@ -29,6 +29,10 @@ import javax.persistence.SharedCacheMode;
|
|||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cache.spi.access.AccessType;
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.engine.spi.FilterDefinition;
|
||||
import org.hibernate.metamodel.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.binding.IdGenerator;
|
||||
import org.hibernate.metamodel.binding.TypeDef;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
@ -43,9 +47,21 @@ public interface Metadata {
|
|||
public SharedCacheMode getSharedCacheMode();
|
||||
public AccessType getDefaultAccessType();
|
||||
public boolean useNewIdentifierGenerators();
|
||||
public String getDefaultSchemaName();
|
||||
public String getDefaultCatalogName();
|
||||
}
|
||||
|
||||
public Options getOptions();
|
||||
|
||||
public SessionFactory buildSessionFactory();
|
||||
|
||||
public Iterable<EntityBinding> getEntityBindings();
|
||||
|
||||
public EntityBinding getEntityBinding(String entityName);
|
||||
|
||||
public Iterable<TypeDef> getTypeDefinitions();
|
||||
|
||||
public Iterable<FilterDefinition> getFilterDefinitions();
|
||||
|
||||
public IdGenerator getIdGenerator(String name);
|
||||
}
|
||||
|
|
|
@ -27,13 +27,11 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.metamodel.binding.state.AttributeBindingState;
|
||||
import org.hibernate.metamodel.domain.Attribute;
|
||||
import org.hibernate.metamodel.domain.MetaAttribute;
|
||||
import org.hibernate.metamodel.relational.Column;
|
||||
import org.hibernate.metamodel.relational.DerivedValue;
|
||||
import org.hibernate.metamodel.relational.SimpleValue;
|
||||
|
@ -43,6 +41,7 @@ import org.hibernate.metamodel.relational.state.SimpleValueRelationalState;
|
|||
import org.hibernate.metamodel.relational.state.TupleRelationalState;
|
||||
import org.hibernate.metamodel.relational.state.ValueCreator;
|
||||
import org.hibernate.metamodel.relational.state.ValueRelationalState;
|
||||
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* TODO : javadoc
|
||||
|
@ -66,7 +65,7 @@ public abstract class AbstractAttributeBinding implements AttributeBinding {
|
|||
// DOM4J specific...
|
||||
private String nodeName;
|
||||
|
||||
private Map<String, MetaAttribute> metaAttributes;
|
||||
private MetaAttributeContext metaAttributeContext;
|
||||
|
||||
protected AbstractAttributeBinding(EntityBinding entityBinding) {
|
||||
this.entityBinding = entityBinding;
|
||||
|
@ -81,7 +80,7 @@ public abstract class AbstractAttributeBinding implements AttributeBinding {
|
|||
cascadeTypes = state.getCascadeTypes();
|
||||
optimisticLockable = state.isOptimisticLockable();
|
||||
nodeName = state.getNodeName();
|
||||
metaAttributes = state.getMetaAttributes();
|
||||
metaAttributeContext = state.getMetaAttributeContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -158,8 +157,8 @@ public abstract class AbstractAttributeBinding implements AttributeBinding {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<String, MetaAttribute> getMetaAttributes() {
|
||||
return metaAttributes;
|
||||
public MetaAttributeContext getMetaAttributeContext() {
|
||||
return metaAttributeContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,13 +23,12 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.binding;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.metamodel.domain.Attribute;
|
||||
import org.hibernate.metamodel.domain.MetaAttribute;
|
||||
import org.hibernate.metamodel.relational.SimpleValue;
|
||||
import org.hibernate.metamodel.relational.Value;
|
||||
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* The basic contract for binding between an {@link #getAttribute() attribute} and a {@link #getValue() value}
|
||||
|
@ -66,11 +65,11 @@ public interface AttributeBinding {
|
|||
public HibernateTypeDescriptor getHibernateTypeDescriptor();
|
||||
|
||||
/**
|
||||
* Obtain the map of meta attributes associated with this binding
|
||||
* Obtain the meta attributes associated with this binding
|
||||
*
|
||||
* @return The meta attributes
|
||||
*/
|
||||
public Map<String, MetaAttribute> getMetaAttributes();
|
||||
public MetaAttributeContext getMetaAttributeContext();
|
||||
|
||||
/**
|
||||
* @return In the case that {@link #getValue()} represents a {@link org.hibernate.metamodel.relational.Tuple} this method
|
||||
|
|
|
@ -35,17 +35,17 @@ import org.hibernate.MappingException;
|
|||
import org.hibernate.engine.internal.Versioning;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.metamodel.domain.Entity;
|
||||
import org.hibernate.metamodel.domain.MetaAttribute;
|
||||
import org.hibernate.metamodel.relational.Column;
|
||||
import org.hibernate.metamodel.relational.TableSpecification;
|
||||
import org.hibernate.metamodel.source.hbm.HbmHelper;
|
||||
import org.hibernate.metamodel.source.hbm.MappingDefaults;
|
||||
import org.hibernate.metamodel.source.hbm.util.MappingHelper;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLClass;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlDeleteElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlInsertElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlUpdateElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSynchronizeElement;
|
||||
import org.hibernate.metamodel.source.hbm.util.MappingHelper;
|
||||
import org.hibernate.metamodel.source.spi.BindingContext;
|
||||
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* Provides the link between the domain and the relational model for an entity.
|
||||
|
@ -68,7 +68,7 @@ public class EntityBinding {
|
|||
|
||||
private Caching caching;
|
||||
|
||||
private Map<String, MetaAttribute> metaAttributes;
|
||||
private MetaAttributeContext metaAttributeContext;
|
||||
|
||||
private String proxyInterfaceName;
|
||||
private boolean lazy;
|
||||
|
@ -95,12 +95,14 @@ public class EntityBinding {
|
|||
private List<String> synchronizedTableNames;
|
||||
|
||||
// TODO: change to intialize from Doimain
|
||||
public void fromHbmXml(MappingDefaults defaults, XMLClass entityClazz, Entity entity) {
|
||||
public void fromHbmXml(BindingContext bindingContext, XMLClass entityClazz, Entity entity) {
|
||||
this.entity = entity;
|
||||
metaAttributes = HbmHelper.extractMetas( entityClazz.getMeta(), true, defaults.getMappingMetas() );
|
||||
metaAttributeContext = HbmHelper.extractMetaAttributeContext( entityClazz.getMeta(), true, bindingContext.getMetaAttributeContext() );
|
||||
|
||||
// go ahead and set the lazy here, since pojo.proxy can override it.
|
||||
lazy = MappingHelper.getBooleanValue( entityClazz.isLazy(), defaults.isDefaultLazy() );
|
||||
lazy = MappingHelper.getBooleanValue(
|
||||
entityClazz.isLazy(), bindingContext.getMappingDefaults().isDefaultLazy()
|
||||
);
|
||||
proxyInterfaceName = entityClazz.getProxy();
|
||||
dynamicUpdate = entityClazz.isDynamicUpdate();
|
||||
dynamicInsert = entityClazz.isDynamicInsert();
|
||||
|
@ -295,12 +297,8 @@ public class EntityBinding {
|
|||
this.caching = caching;
|
||||
}
|
||||
|
||||
public Map<String, MetaAttribute> getMetaAttributes() {
|
||||
return metaAttributes;
|
||||
}
|
||||
|
||||
public void setMetaAttributes(Map<String, MetaAttribute> metaAttributes) {
|
||||
this.metaAttributes = metaAttributes;
|
||||
public MetaAttributeContext getMetaAttributeContext() {
|
||||
return metaAttributeContext;
|
||||
}
|
||||
|
||||
public boolean isMutable() {
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Set;
|
|||
|
||||
import org.hibernate.metamodel.binding.CascadeType;
|
||||
import org.hibernate.metamodel.domain.MetaAttribute;
|
||||
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
|
@ -51,5 +52,5 @@ public interface AttributeBindingState {
|
|||
|
||||
String getNodeName();
|
||||
|
||||
Map<String, MetaAttribute> getMetaAttributes();
|
||||
public MetaAttributeContext getMetaAttributeContext();
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ import java.util.Set;
|
|||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.binding.CascadeType;
|
||||
import org.hibernate.metamodel.binding.state.SimpleAttributeBindingState;
|
||||
import org.hibernate.metamodel.domain.MetaAttribute;
|
||||
import org.hibernate.metamodel.source.annotations.entity.SimpleAttribute;
|
||||
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* Implementation of the attribute binding state via annotation configuration.
|
||||
|
@ -117,7 +117,7 @@ public class AttributeBindingStateImpl implements SimpleAttributeBindingState {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<String, MetaAttribute> getMetaAttributes() {
|
||||
public MetaAttributeContext getMetaAttributeContext() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,8 @@ import org.hibernate.metamodel.source.annotations.entity.SimpleAttribute;
|
|||
* @author Gail Badner
|
||||
*/
|
||||
public class DiscriminatorBindingStateImpl
|
||||
extends AttributeBindingStateImpl implements DiscriminatorBindingState {
|
||||
extends AttributeBindingStateImpl
|
||||
implements DiscriminatorBindingState {
|
||||
private final String discriminatorValue;
|
||||
private final boolean isForced;
|
||||
private final boolean isInserted;
|
||||
|
|
|
@ -92,10 +92,10 @@ abstract class AbstractEntityBinder {
|
|||
this.hibernateMappingBinder = hibernateMappingBinder;
|
||||
this.schemaName = new Schema.Name(
|
||||
( entityClazz.getSchema() == null ?
|
||||
hibernateMappingBinder.getDefaultSchemaName() :
|
||||
hibernateMappingBinder.getMappingDefaults().getDefaultSchemaName() :
|
||||
entityClazz.getSchema() ),
|
||||
( entityClazz.getCatalog() == null ?
|
||||
hibernateMappingBinder.getDefaultCatalogName() :
|
||||
hibernateMappingBinder.getMappingDefaults().getDefaultCatalogName() :
|
||||
entityClazz.getCatalog() )
|
||||
);
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ abstract class AbstractEntityBinder {
|
|||
}
|
||||
|
||||
protected String getDefaultAccess() {
|
||||
return hibernateMappingBinder.getDefaultAccess();
|
||||
return hibernateMappingBinder.getMappingDefaults().getDefaultAccess();
|
||||
}
|
||||
|
||||
private void bindPojoRepresentation(XMLHibernateMapping.XMLClass entityClazz,
|
||||
|
@ -439,12 +439,13 @@ PrimitiveArray
|
|||
|
||||
}
|
||||
|
||||
protected SimpleAttributeBinding bindProperty(XMLPropertyElement property,
|
||||
EntityBinding entityBinding) {
|
||||
protected SimpleAttributeBinding bindProperty(
|
||||
XMLPropertyElement property,
|
||||
EntityBinding entityBinding) {
|
||||
SimpleAttributeBindingState bindingState = new HbmSimpleAttributeBindingState(
|
||||
entityBinding.getEntity().getPojoEntitySpecifics().getClassName(),
|
||||
hibernateMappingBinder,
|
||||
entityBinding.getMetaAttributes(),
|
||||
entityBinding.getMetaAttributeContext(),
|
||||
property
|
||||
);
|
||||
|
||||
|
@ -483,8 +484,8 @@ PrimitiveArray
|
|||
new HbmPluralAttributeBindingState(
|
||||
entityBinding.getEntity().getPojoEntitySpecifics().getClassName(),
|
||||
hibernateMappingBinder,
|
||||
collection,
|
||||
entityBinding.getMetaAttributes()
|
||||
entityBinding.getMetaAttributeContext(),
|
||||
collection
|
||||
);
|
||||
|
||||
BagBinding collectionBinding = entityBinding.makeBagAttributeBinding(
|
||||
|
@ -523,7 +524,7 @@ PrimitiveArray
|
|||
new HbmManyToOneAttributeBindingState(
|
||||
entityBinding.getEntity().getPojoEntitySpecifics().getClassName(),
|
||||
hibernateMappingBinder,
|
||||
entityBinding.getMetaAttributes(),
|
||||
entityBinding.getMetaAttributeContext(),
|
||||
manyToOne
|
||||
);
|
||||
|
||||
|
|
|
@ -32,15 +32,13 @@ import java.util.Set;
|
|||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.engine.spi.FilterDefinition;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.metamodel.relational.AuxiliaryDatabaseObject;
|
||||
import org.hibernate.metamodel.binding.FetchProfile;
|
||||
import org.hibernate.metamodel.binding.FetchProfile.Fetch;
|
||||
import org.hibernate.metamodel.binding.TypeDef;
|
||||
import org.hibernate.metamodel.domain.MetaAttribute;
|
||||
import org.hibernate.metamodel.relational.AuxiliaryDatabaseObject;
|
||||
import org.hibernate.metamodel.relational.BasicAuxiliaryDatabaseObjectImpl;
|
||||
import org.hibernate.metamodel.source.MappingException;
|
||||
import org.hibernate.metamodel.source.Origin;
|
||||
import org.hibernate.metamodel.source.hbm.util.MappingHelper;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLFetchProfileElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLFetchProfileElement.XMLFetch;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping;
|
||||
|
@ -53,6 +51,10 @@ import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlQueryElement;
|
|||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSubclassElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLUnionSubclassElement;
|
||||
import org.hibernate.metamodel.source.internal.JaxbRoot;
|
||||
import org.hibernate.metamodel.source.internal.OverriddenMappingDefaults;
|
||||
import org.hibernate.metamodel.source.spi.BindingContext;
|
||||
import org.hibernate.metamodel.source.spi.MappingDefaults;
|
||||
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
|
||||
import org.hibernate.metamodel.source.spi.MetadataImplementor;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
|
@ -62,42 +64,45 @@ import org.hibernate.type.Type;
|
|||
/**
|
||||
* Responsible for performing binding of hbm xml.
|
||||
*/
|
||||
public class HbmBinder implements MappingDefaults {
|
||||
private static final String DEFAULT_IDENTIFIER_COLUMN_NAME = "id";
|
||||
private static final String DEFAULT_DISCRIMINATOR_COLUMN_NAME = "class";
|
||||
public class HbmBinder implements BindingContext {
|
||||
|
||||
private final JaxbRoot<XMLHibernateMapping> jaxbRoot;
|
||||
private final XMLHibernateMapping hibernateMapping;
|
||||
|
||||
private final String defaultSchemaName;
|
||||
private final String defaultCatalogName;
|
||||
private final String defaultCascade;
|
||||
private final String defaultAccess;
|
||||
private final boolean defaultLazy;
|
||||
private final String packageName;
|
||||
private final MappingDefaults mappingDefaults;
|
||||
private final MetaAttributeContext metaAttributeContext;
|
||||
|
||||
private final boolean autoImport;
|
||||
|
||||
private final MetadataImplementor metadata;
|
||||
private final Map<String, MetaAttribute> globalMetas;
|
||||
|
||||
private Map<String, MetaAttribute> mappingMetas;
|
||||
|
||||
public HbmBinder(MetadataImplementor metadata, Map<String, MetaAttribute> globalMetas, JaxbRoot<XMLHibernateMapping> jaxbRoot) {
|
||||
public HbmBinder(MetadataImplementor metadata, JaxbRoot<XMLHibernateMapping> jaxbRoot) {
|
||||
this.jaxbRoot = jaxbRoot;
|
||||
this.hibernateMapping = jaxbRoot.getRoot();
|
||||
|
||||
this.metadata = metadata;
|
||||
this.globalMetas = globalMetas;
|
||||
|
||||
defaultSchemaName = hibernateMapping.getSchema();
|
||||
defaultCatalogName = hibernateMapping.getCatalog();
|
||||
defaultCascade = MappingHelper.getStringValue( hibernateMapping.getDefaultCascade(), "none" );
|
||||
defaultAccess = MappingHelper.getStringValue( hibernateMapping.getDefaultAccess(), "property" );
|
||||
defaultLazy = hibernateMapping.isDefaultLazy();
|
||||
packageName = hibernateMapping.getPackage();
|
||||
this.mappingDefaults = new OverriddenMappingDefaults(
|
||||
metadata.getMappingDefaults(),
|
||||
hibernateMapping.getPackage(),
|
||||
hibernateMapping.getSchema(),
|
||||
hibernateMapping.getCatalog(),
|
||||
null,
|
||||
null,
|
||||
hibernateMapping.getDefaultCascade(),
|
||||
hibernateMapping.getDefaultAccess(),
|
||||
hibernateMapping.isDefaultLazy()
|
||||
);
|
||||
|
||||
autoImport = hibernateMapping.isAutoImport();
|
||||
|
||||
mappingMetas = HbmHelper.extractMetas( hibernateMapping.getMeta(), true, globalMetas );
|
||||
metaAttributeContext = extractMetaAttributes();
|
||||
}
|
||||
|
||||
private MetaAttributeContext extractMetaAttributes() {
|
||||
return hibernateMapping.getMeta() == null
|
||||
? new MetaAttributeContext( metadata.getMetaAttributeContext() )
|
||||
: HbmHelper.extractMetaAttributeContext( hibernateMapping.getMeta(), true, metadata.getMetaAttributeContext() );
|
||||
}
|
||||
|
||||
public MetadataImplementor getMetadata() {
|
||||
|
@ -108,113 +113,62 @@ public class HbmBinder implements MappingDefaults {
|
|||
return jaxbRoot.getOrigin();
|
||||
}
|
||||
|
||||
public String getDefaultSchemaName() {
|
||||
return defaultSchemaName;
|
||||
}
|
||||
|
||||
public String getDefaultCatalogName() {
|
||||
return defaultCatalogName;
|
||||
}
|
||||
|
||||
public String getDefaultIdColumnName() {
|
||||
return DEFAULT_IDENTIFIER_COLUMN_NAME;
|
||||
}
|
||||
|
||||
public String getDefaultDiscriminatorColumnName() {
|
||||
return DEFAULT_DISCRIMINATOR_COLUMN_NAME;
|
||||
}
|
||||
|
||||
public String getDefaultCascade() {
|
||||
return defaultCascade;
|
||||
}
|
||||
|
||||
public String getDefaultAccess() {
|
||||
return defaultAccess;
|
||||
}
|
||||
|
||||
public boolean isDefaultLazy() {
|
||||
return defaultLazy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceRegistry getServiceRegistry() {
|
||||
return metadata.getServiceRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamingStrategy getNamingStrategy() {
|
||||
return metadata.getOptions().getNamingStrategy();
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
@Override
|
||||
public MappingDefaults getMappingDefaults() {
|
||||
return mappingDefaults;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaAttributeContext getMetaAttributeContext() {
|
||||
return metaAttributeContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataImplementor getMetadataImplementor() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
boolean isAutoImport() {
|
||||
return autoImport;
|
||||
}
|
||||
|
||||
public Map<String, MetaAttribute> getMappingMetas() {
|
||||
return mappingMetas;
|
||||
}
|
||||
|
||||
public void processHibernateMapping() {
|
||||
// perform bindings with no pre-requisites
|
||||
// no pre-requisites
|
||||
bindDatabaseObjectDefinitions();
|
||||
|
||||
// no pre-requisites
|
||||
bindTypeDefinitions();
|
||||
|
||||
// potentially depends on type definitions
|
||||
bindFilterDefinitions();
|
||||
|
||||
// potentially depends on type definitions
|
||||
bindIdentifierGenerators();
|
||||
|
||||
if ( hibernateMapping.getClazzOrSubclassOrJoinedSubclass() != null ) {
|
||||
for ( Object clazzOrSubclass : hibernateMapping.getClazzOrSubclassOrJoinedSubclass() ) {
|
||||
if ( XMLClass.class.isInstance( clazzOrSubclass ) ) {
|
||||
XMLClass clazz =
|
||||
XMLClass.class.cast( clazzOrSubclass );
|
||||
new RootEntityBinder( this, clazz ).process( clazz );
|
||||
}
|
||||
else if ( XMLSubclassElement.class.isInstance( clazzOrSubclass ) ) {
|
||||
// PersistentClass superModel = getSuperclass( mappings, element );
|
||||
// handleSubclass( superModel, mappings, element, inheritedMetas );
|
||||
}
|
||||
else if ( XMLJoinedSubclassElement.class.isInstance( clazzOrSubclass ) ) {
|
||||
// PersistentClass superModel = getSuperclass( mappings, element );
|
||||
// handleJoinedSubclass( superModel, mappings, element, inheritedMetas );
|
||||
}
|
||||
else if ( XMLUnionSubclassElement.class.isInstance( clazzOrSubclass ) ) {
|
||||
// PersistentClass superModel = getSuperclass( mappings, element );
|
||||
// handleUnionSubclass( superModel, mappings, element, inheritedMetas );
|
||||
}
|
||||
else {
|
||||
throw new org.hibernate.metamodel.source.MappingException(
|
||||
"unknown type of class or subclass: " +
|
||||
clazzOrSubclass.getClass().getName(), jaxbRoot.getOrigin()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
// potentially depends on type definitions and identifier generators
|
||||
bindMappings();
|
||||
|
||||
// depends on mappings
|
||||
bindFetchProfiles();
|
||||
|
||||
// depends on mappings
|
||||
bindImports();
|
||||
|
||||
if ( hibernateMapping.getQueryOrSqlQuery() != null ) {
|
||||
for ( Object queryOrSqlQuery : hibernateMapping.getQueryOrSqlQuery() ) {
|
||||
if ( XMLQueryElement.class.isInstance( queryOrSqlQuery ) ) {
|
||||
// bindNamedQuery( element, null, mappings );
|
||||
}
|
||||
else if ( XMLSqlQueryElement.class.isInstance( queryOrSqlQuery ) ) {
|
||||
// bindNamedSQLQuery( element, null, mappings );
|
||||
}
|
||||
else {
|
||||
throw new MappingException(
|
||||
"unknown type of query: " +
|
||||
queryOrSqlQuery.getClass().getName(), jaxbRoot.getOrigin()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( hibernateMapping.getResultset() != null ) {
|
||||
// bindResultSetMappingDefinitions( element, null, mappings );
|
||||
}
|
||||
// depends on mappings and potentially on type definitions
|
||||
bindResultSetMappings();
|
||||
|
||||
// depends on mappings and potentially on type definitions and result set mappings
|
||||
bindNamedQueries();
|
||||
}
|
||||
|
||||
private void bindDatabaseObjectDefinitions() {
|
||||
|
@ -268,56 +222,6 @@ public class HbmBinder implements MappingDefaults {
|
|||
}
|
||||
}
|
||||
|
||||
private void bindIdentifierGenerators() {
|
||||
if ( hibernateMapping.getIdentifierGenerator() == null ) {
|
||||
return;
|
||||
}
|
||||
for ( XMLHibernateMapping.XMLIdentifierGenerator identifierGeneratorElement : hibernateMapping.getIdentifierGenerator() ) {
|
||||
metadata.registerIdentifierGenerator(
|
||||
identifierGeneratorElement.getName(),
|
||||
identifierGeneratorElement.getClazz()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private void bindImports() {
|
||||
if ( hibernateMapping.getImport() == null ) {
|
||||
return;
|
||||
}
|
||||
for ( XMLImport importValue : hibernateMapping.getImport() ) {
|
||||
String className = getClassName( importValue.getClazz() );
|
||||
String rename = importValue.getRename();
|
||||
rename = ( rename == null ) ? StringHelper.unqualify( className ) : rename;
|
||||
metadata.addImport( className, rename );
|
||||
}
|
||||
}
|
||||
|
||||
private void bindFetchProfiles(){
|
||||
if(hibernateMapping.getFetchProfile() == null){
|
||||
return;
|
||||
}
|
||||
bindFetchProfiles( hibernateMapping.getFetchProfile(),null );
|
||||
}
|
||||
|
||||
protected void bindFetchProfiles(List<XMLFetchProfileElement> fetchProfiles, String containingEntityName) {
|
||||
for ( XMLFetchProfileElement fetchProfile : fetchProfiles ) {
|
||||
String profileName = fetchProfile.getName();
|
||||
Set<Fetch> fetches = new HashSet<Fetch>();
|
||||
for ( XMLFetch fetch : fetchProfile.getFetch() ) {
|
||||
String entityName = fetch.getEntity() == null ? containingEntityName : fetch.getEntity();
|
||||
if ( entityName == null ) {
|
||||
throw new MappingException(
|
||||
"could not determine entity for fetch-profile fetch [" + profileName + "]:[" +
|
||||
fetch.getAssociation() + "]",
|
||||
jaxbRoot.getOrigin()
|
||||
);
|
||||
}
|
||||
fetches.add( new Fetch( entityName, fetch.getAssociation(), fetch.getStyle() ) );
|
||||
}
|
||||
metadata.addFetchProfile( new FetchProfile( profileName, fetches ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void bindFilterDefinitions() {
|
||||
if(hibernateMapping.getFilterDef() == null){
|
||||
return;
|
||||
|
@ -353,6 +257,114 @@ public class HbmBinder implements MappingDefaults {
|
|||
}
|
||||
}
|
||||
|
||||
private void bindIdentifierGenerators() {
|
||||
if ( hibernateMapping.getIdentifierGenerator() == null ) {
|
||||
return;
|
||||
}
|
||||
for ( XMLHibernateMapping.XMLIdentifierGenerator identifierGeneratorElement : hibernateMapping.getIdentifierGenerator() ) {
|
||||
metadata.registerIdentifierGenerator(
|
||||
identifierGeneratorElement.getName(),
|
||||
identifierGeneratorElement.getClazz()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private void bindMappings() {
|
||||
if ( hibernateMapping.getClazzOrSubclassOrJoinedSubclass() == null ) {
|
||||
return;
|
||||
}
|
||||
for ( Object clazzOrSubclass : hibernateMapping.getClazzOrSubclassOrJoinedSubclass() ) {
|
||||
if ( XMLClass.class.isInstance( clazzOrSubclass ) ) {
|
||||
XMLClass clazz =
|
||||
XMLClass.class.cast( clazzOrSubclass );
|
||||
new RootEntityBinder( this, clazz ).process( clazz );
|
||||
}
|
||||
else if ( XMLSubclassElement.class.isInstance( clazzOrSubclass ) ) {
|
||||
// PersistentClass superModel = getSuperclass( mappings, element );
|
||||
// handleSubclass( superModel, mappings, element, inheritedMetas );
|
||||
}
|
||||
else if ( XMLJoinedSubclassElement.class.isInstance( clazzOrSubclass ) ) {
|
||||
// PersistentClass superModel = getSuperclass( mappings, element );
|
||||
// handleJoinedSubclass( superModel, mappings, element, inheritedMetas );
|
||||
}
|
||||
else if ( XMLUnionSubclassElement.class.isInstance( clazzOrSubclass ) ) {
|
||||
// PersistentClass superModel = getSuperclass( mappings, element );
|
||||
// handleUnionSubclass( superModel, mappings, element, inheritedMetas );
|
||||
}
|
||||
else {
|
||||
throw new org.hibernate.metamodel.source.MappingException(
|
||||
"unknown type of class or subclass: " +
|
||||
clazzOrSubclass.getClass().getName(), jaxbRoot.getOrigin()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void bindFetchProfiles(){
|
||||
if(hibernateMapping.getFetchProfile() == null){
|
||||
return;
|
||||
}
|
||||
bindFetchProfiles( hibernateMapping.getFetchProfile(),null );
|
||||
}
|
||||
|
||||
protected void bindFetchProfiles(List<XMLFetchProfileElement> fetchProfiles, String containingEntityName) {
|
||||
for ( XMLFetchProfileElement fetchProfile : fetchProfiles ) {
|
||||
String profileName = fetchProfile.getName();
|
||||
Set<Fetch> fetches = new HashSet<Fetch>();
|
||||
for ( XMLFetch fetch : fetchProfile.getFetch() ) {
|
||||
String entityName = fetch.getEntity() == null ? containingEntityName : fetch.getEntity();
|
||||
if ( entityName == null ) {
|
||||
throw new MappingException(
|
||||
"could not determine entity for fetch-profile fetch [" + profileName + "]:[" +
|
||||
fetch.getAssociation() + "]",
|
||||
jaxbRoot.getOrigin()
|
||||
);
|
||||
}
|
||||
fetches.add( new Fetch( entityName, fetch.getAssociation(), fetch.getStyle() ) );
|
||||
}
|
||||
metadata.addFetchProfile( new FetchProfile( profileName, fetches ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void bindImports() {
|
||||
if ( hibernateMapping.getImport() == null ) {
|
||||
return;
|
||||
}
|
||||
for ( XMLImport importValue : hibernateMapping.getImport() ) {
|
||||
String className = getClassName( importValue.getClazz() );
|
||||
String rename = importValue.getRename();
|
||||
rename = ( rename == null ) ? StringHelper.unqualify( className ) : rename;
|
||||
metadata.addImport( className, rename );
|
||||
}
|
||||
}
|
||||
|
||||
private void bindResultSetMappings() {
|
||||
if ( hibernateMapping.getResultset() == null ) {
|
||||
return;
|
||||
}
|
||||
// bindResultSetMappingDefinitions( element, null, mappings );
|
||||
}
|
||||
|
||||
private void bindNamedQueries() {
|
||||
if ( hibernateMapping.getQueryOrSqlQuery() == null ) {
|
||||
return;
|
||||
}
|
||||
for ( Object queryOrSqlQuery : hibernateMapping.getQueryOrSqlQuery() ) {
|
||||
if ( XMLQueryElement.class.isInstance( queryOrSqlQuery ) ) {
|
||||
// bindNamedQuery( element, null, mappings );
|
||||
}
|
||||
else if ( XMLSqlQueryElement.class.isInstance( queryOrSqlQuery ) ) {
|
||||
// bindNamedSQLQuery( element, null, mappings );
|
||||
}
|
||||
else {
|
||||
throw new MappingException(
|
||||
"unknown type of query: " +
|
||||
queryOrSqlQuery.getClass().getName(), jaxbRoot.getOrigin()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ClassLoaderService classLoaderService;
|
||||
|
||||
private ClassLoaderService classLoaderService() {
|
||||
|
@ -363,10 +375,10 @@ public class HbmBinder implements MappingDefaults {
|
|||
}
|
||||
|
||||
String extractEntityName(XMLClass entityClazz) {
|
||||
return HbmHelper.extractEntityName( entityClazz, packageName );
|
||||
return HbmHelper.extractEntityName( entityClazz, mappingDefaults.getPackageName() );
|
||||
}
|
||||
|
||||
String getClassName(String unqualifiedName) {
|
||||
return HbmHelper.getClassName( unqualifiedName, packageName );
|
||||
return HbmHelper.getClassName( unqualifiedName, mappingDefaults.getPackageName() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.hibernate.metamodel.domain.MetaAttribute;
|
|||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLClass;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLMetaElement;
|
||||
import org.hibernate.metamodel.source.hbm.util.MappingHelper;
|
||||
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* TODO : javadoc
|
||||
|
@ -128,4 +129,34 @@ public class HbmHelper {
|
|||
isEmbedded ? "embedded" : defaultAccess
|
||||
);
|
||||
}
|
||||
|
||||
public static MetaAttributeContext extractMetaAttributeContext(
|
||||
List<XMLMetaElement> metaElementList,
|
||||
MetaAttributeContext parentContext) {
|
||||
return extractMetaAttributeContext( metaElementList, false, parentContext );
|
||||
}
|
||||
|
||||
public static MetaAttributeContext extractMetaAttributeContext(
|
||||
List<XMLMetaElement> metaElementList,
|
||||
boolean onlyInheritable,
|
||||
MetaAttributeContext parentContext) {
|
||||
final MetaAttributeContext subContext = new MetaAttributeContext( parentContext );
|
||||
|
||||
for ( XMLMetaElement metaElement : metaElementList ) {
|
||||
if ( onlyInheritable & !metaElement.isInherit() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String name = metaElement.getAttribute();
|
||||
final MetaAttribute inheritedMetaAttribute = parentContext.getMetaAttribute( name );
|
||||
MetaAttribute metaAttribute = subContext.getLocalMetaAttribute( name );
|
||||
if ( metaAttribute == null || metaAttribute == inheritedMetaAttribute ) {
|
||||
metaAttribute = new MetaAttribute( name );
|
||||
subContext.add( metaAttribute );
|
||||
}
|
||||
metaAttribute.addValue( metaElement.getValue() );
|
||||
}
|
||||
|
||||
return subContext;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ class RootEntityBinder extends AbstractEntityBinder {
|
|||
SimpleAttributeBindingState bindingState = new HbmSimpleAttributeBindingState(
|
||||
entityBinding.getEntity().getPojoEntitySpecifics().getClassName(),
|
||||
getHibernateMappingBinder(),
|
||||
entityBinding.getMetaAttributes(),
|
||||
entityBinding.getMetaAttributeContext(),
|
||||
id
|
||||
);
|
||||
// boolean (true here) indicates that by default column names should be guessed
|
||||
|
@ -289,7 +289,7 @@ class RootEntityBinder extends AbstractEntityBinder {
|
|||
new HbmSimpleAttributeBindingState(
|
||||
entityBinding.getEntity().getPojoEntitySpecifics().getClassName(),
|
||||
getHibernateMappingBinder(),
|
||||
entityBinding.getMetaAttributes(),
|
||||
entityBinding.getMetaAttributeContext(),
|
||||
version
|
||||
);
|
||||
|
||||
|
@ -316,7 +316,7 @@ class RootEntityBinder extends AbstractEntityBinder {
|
|||
new HbmSimpleAttributeBindingState(
|
||||
entityBinding.getEntity().getPojoEntitySpecifics().getClassName(),
|
||||
getHibernateMappingBinder(),
|
||||
entityBinding.getMetaAttributes(),
|
||||
entityBinding.getMetaAttributeContext(),
|
||||
timestamp
|
||||
);
|
||||
|
||||
|
|
|
@ -32,9 +32,10 @@ import org.hibernate.internal.util.ReflectHelper;
|
|||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.binding.CascadeType;
|
||||
import org.hibernate.metamodel.binding.state.AttributeBindingState;
|
||||
import org.hibernate.metamodel.domain.MetaAttribute;
|
||||
import org.hibernate.metamodel.source.hbm.MappingDefaults;
|
||||
import org.hibernate.metamodel.source.hbm.util.MappingHelper;
|
||||
import org.hibernate.metamodel.source.spi.BindingContext;
|
||||
import org.hibernate.metamodel.source.spi.MappingDefaults;
|
||||
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
|
@ -42,18 +43,18 @@ import org.hibernate.metamodel.source.hbm.util.MappingHelper;
|
|||
public abstract class AbstractHbmAttributeBindingState implements AttributeBindingState {
|
||||
private final String ownerClassName;
|
||||
private final String attributeName;
|
||||
private final MappingDefaults defaults;
|
||||
private final BindingContext bindingContext;
|
||||
private final String nodeName;
|
||||
private final String accessorName;
|
||||
private final boolean isOptimisticLockable;
|
||||
private final Map<String, MetaAttribute> metaAttributes;
|
||||
private final MetaAttributeContext metaAttributeContext;
|
||||
|
||||
public AbstractHbmAttributeBindingState(
|
||||
String ownerClassName,
|
||||
String attributeName,
|
||||
MappingDefaults defaults,
|
||||
BindingContext bindingContext,
|
||||
String nodeName,
|
||||
Map<String, MetaAttribute> metaAttributes,
|
||||
MetaAttributeContext metaAttributeContext,
|
||||
String accessorName,
|
||||
boolean isOptimisticLockable) {
|
||||
if ( attributeName == null ) {
|
||||
|
@ -64,9 +65,9 @@ public abstract class AbstractHbmAttributeBindingState implements AttributeBindi
|
|||
|
||||
this.ownerClassName = ownerClassName;
|
||||
this.attributeName = attributeName;
|
||||
this.defaults = defaults;
|
||||
this.bindingContext = bindingContext;
|
||||
this.nodeName = nodeName;
|
||||
this.metaAttributes = metaAttributes;
|
||||
this.metaAttributeContext = metaAttributeContext;
|
||||
this.accessorName = accessorName;
|
||||
this.isOptimisticLockable = isOptimisticLockable;
|
||||
}
|
||||
|
@ -77,7 +78,7 @@ public abstract class AbstractHbmAttributeBindingState implements AttributeBindi
|
|||
}
|
||||
|
||||
protected Set<CascadeType> determineCascadeTypes(String cascade) {
|
||||
String commaSeparatedCascades = MappingHelper.getStringValue( cascade, getDefaults().getDefaultCascade() );
|
||||
String commaSeparatedCascades = MappingHelper.getStringValue( cascade, getBindingContext().getMappingDefaults().getDefaultCascade() );
|
||||
Set<String> cascades = MappingHelper.getStringValueTokens( commaSeparatedCascades, "," );
|
||||
Set<CascadeType> cascadeTypes = new HashSet<CascadeType>( cascades.size() );
|
||||
for ( String s : cascades ) {
|
||||
|
@ -91,7 +92,7 @@ public abstract class AbstractHbmAttributeBindingState implements AttributeBindi
|
|||
}
|
||||
|
||||
protected final String getTypeNameByReflection() {
|
||||
Class ownerClass = MappingHelper.classForName( ownerClassName, defaults.getServiceRegistry() );
|
||||
Class ownerClass = MappingHelper.classForName( ownerClassName, bindingContext.getServiceRegistry() );
|
||||
return ReflectHelper.reflectedPropertyClass( ownerClass, attributeName ).getName();
|
||||
}
|
||||
|
||||
|
@ -99,29 +100,39 @@ public abstract class AbstractHbmAttributeBindingState implements AttributeBindi
|
|||
return attributeName;
|
||||
}
|
||||
|
||||
protected final MappingDefaults getDefaults() {
|
||||
return defaults;
|
||||
public BindingContext getBindingContext() {
|
||||
return bindingContext;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected final MappingDefaults getDefaults() {
|
||||
return getBindingContext().getMappingDefaults();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getPropertyAccessorName() {
|
||||
return accessorName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isAlternateUniqueKey() {
|
||||
//TODO: implement
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isOptimisticLockable() {
|
||||
return isOptimisticLockable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getNodeName() {
|
||||
return nodeName == null ? getAttributeName() : nodeName;
|
||||
}
|
||||
|
||||
public final Map<String, MetaAttribute> getMetaAttributes() {
|
||||
return metaAttributes;
|
||||
@Override
|
||||
public MetaAttributeContext getMetaAttributeContext() {
|
||||
return metaAttributeContext;
|
||||
}
|
||||
|
||||
public PropertyGeneration getPropertyGeneration() {
|
||||
|
|
|
@ -26,16 +26,17 @@ package org.hibernate.metamodel.source.hbm.state.binding;
|
|||
import java.util.Set;
|
||||
|
||||
import org.hibernate.metamodel.binding.CascadeType;
|
||||
import org.hibernate.metamodel.source.hbm.MappingDefaults;
|
||||
import org.hibernate.metamodel.binding.state.DiscriminatorBindingState;
|
||||
import org.hibernate.metamodel.source.hbm.util.MappingHelper;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLClass.XMLDiscriminator;
|
||||
import org.hibernate.metamodel.source.spi.BindingContext;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class HbmDiscriminatorBindingState extends AbstractHbmAttributeBindingState
|
||||
public class HbmDiscriminatorBindingState
|
||||
extends AbstractHbmAttributeBindingState
|
||||
implements DiscriminatorBindingState {
|
||||
private final String discriminatorValue;
|
||||
private final boolean isForced;
|
||||
|
@ -45,12 +46,16 @@ public class HbmDiscriminatorBindingState extends AbstractHbmAttributeBindingSta
|
|||
public HbmDiscriminatorBindingState(
|
||||
String entityName,
|
||||
String ownerClassName,
|
||||
MappingDefaults defaults,
|
||||
BindingContext bindingContext,
|
||||
XMLHibernateMapping.XMLClass xmlEntityClazz) {
|
||||
// Discriminator.getName() is not defined, so the attribute will always be
|
||||
// defaults.getDefaultDescriminatorColumnName()
|
||||
super(
|
||||
ownerClassName, defaults.getDefaultDiscriminatorColumnName(), defaults, null, null, null, true
|
||||
ownerClassName,
|
||||
bindingContext.getMappingDefaults().getDefaultDiscriminatorColumnName(),
|
||||
bindingContext,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
true
|
||||
);
|
||||
XMLDiscriminator discriminator = xmlEntityClazz.getDiscriminator();
|
||||
this.discriminatorValue = MappingHelper.getStringValue(
|
||||
|
|
|
@ -23,20 +23,17 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.source.hbm.state.binding;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.metamodel.binding.CascadeType;
|
||||
import org.hibernate.metamodel.binding.state.ManyToOneAttributeBindingState;
|
||||
import org.hibernate.metamodel.domain.MetaAttribute;
|
||||
import org.hibernate.metamodel.source.hbm.HbmHelper;
|
||||
import org.hibernate.metamodel.source.hbm.MappingDefaults;
|
||||
import org.hibernate.metamodel.source.hbm.util.MappingHelper;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLManyToOneElement;
|
||||
import org.hibernate.metamodel.source.spi.BindingContext;
|
||||
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
|
@ -58,17 +55,19 @@ public class HbmManyToOneAttributeBindingState
|
|||
|
||||
public HbmManyToOneAttributeBindingState(
|
||||
String ownerClassName,
|
||||
MappingDefaults defaults,
|
||||
Map<String, MetaAttribute> entityMetaAttributes,
|
||||
BindingContext bindingContext,
|
||||
MetaAttributeContext parentMetaAttributeContext,
|
||||
XMLManyToOneElement manyToOne) {
|
||||
super(
|
||||
ownerClassName,
|
||||
manyToOne.getName(),
|
||||
defaults,
|
||||
bindingContext,
|
||||
manyToOne.getNode(),
|
||||
HbmHelper.extractMetas( manyToOne.getMeta(), entityMetaAttributes ),
|
||||
HbmHelper.extractMetaAttributeContext( manyToOne.getMeta(), parentMetaAttributeContext ),
|
||||
HbmHelper.getPropertyAccessorName(
|
||||
manyToOne.getAccess(), manyToOne.isEmbedXml(), defaults.getDefaultAccess()
|
||||
manyToOne.getAccess(),
|
||||
manyToOne.isEmbedXml(),
|
||||
bindingContext.getMappingDefaults().getDefaultAccess()
|
||||
),
|
||||
manyToOne.isOptimisticLock()
|
||||
);
|
||||
|
@ -80,7 +79,7 @@ public class HbmManyToOneAttributeBindingState
|
|||
"proxy".equals( manyToOne.getLazy().value() );
|
||||
cascadeTypes = determineCascadeTypes( manyToOne.getCascade() );
|
||||
isEmbedded = manyToOne.isEmbedXml();
|
||||
referencedEntityName = getReferencedEntityName( ownerClassName, manyToOne, defaults );
|
||||
referencedEntityName = getReferencedEntityName( ownerClassName, manyToOne, bindingContext );
|
||||
referencedPropertyName = manyToOne.getPropertyRef();
|
||||
ignoreNotFound = "ignore".equals( manyToOne.getNotFound().value() );
|
||||
isInsertable = manyToOne.isInsert();
|
||||
|
@ -92,16 +91,21 @@ public class HbmManyToOneAttributeBindingState
|
|||
return isEmbedded;
|
||||
}
|
||||
|
||||
private static String getReferencedEntityName(String ownerClassName, XMLManyToOneElement manyToOne, MappingDefaults defaults) {
|
||||
private static String getReferencedEntityName(
|
||||
String ownerClassName,
|
||||
XMLManyToOneElement manyToOne,
|
||||
BindingContext bindingContext) {
|
||||
String referencedEntityName;
|
||||
if ( manyToOne.getEntityName() != null ) {
|
||||
referencedEntityName = manyToOne.getEntityName();
|
||||
}
|
||||
else if ( manyToOne.getClazz() != null ) {
|
||||
referencedEntityName = HbmHelper.getClassName( manyToOne.getClazz(), defaults.getPackageName() );
|
||||
referencedEntityName = HbmHelper.getClassName(
|
||||
manyToOne.getClazz(), bindingContext.getMappingDefaults().getPackageName()
|
||||
);
|
||||
}
|
||||
else {
|
||||
Class ownerClazz = MappingHelper.classForName( ownerClassName, defaults.getServiceRegistry() );
|
||||
Class ownerClazz = MappingHelper.classForName( ownerClassName, bindingContext.getServiceRegistry() );
|
||||
referencedEntityName = ReflectHelper.reflectedPropertyClass( ownerClazz, manyToOne.getName() ).getName();
|
||||
}
|
||||
return referencedEntityName;
|
||||
|
|
|
@ -26,16 +26,13 @@ package org.hibernate.metamodel.source.hbm.state.binding;
|
|||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.metamodel.binding.CascadeType;
|
||||
import org.hibernate.metamodel.binding.CustomSQL;
|
||||
import org.hibernate.metamodel.binding.state.PluralAttributeBindingState;
|
||||
import org.hibernate.metamodel.domain.MetaAttribute;
|
||||
import org.hibernate.metamodel.source.hbm.HbmHelper;
|
||||
import org.hibernate.metamodel.source.hbm.MappingDefaults;
|
||||
import org.hibernate.metamodel.source.hbm.util.MappingHelper;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLBagElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlDeleteAllElement;
|
||||
|
@ -43,6 +40,8 @@ import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlDeleteElement;
|
|||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlInsertElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlUpdateElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSynchronizeElement;
|
||||
import org.hibernate.metamodel.source.spi.BindingContext;
|
||||
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
|
@ -56,23 +55,23 @@ public class HbmPluralAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
|
||||
public HbmPluralAttributeBindingState(
|
||||
String ownerClassName,
|
||||
MappingDefaults mappingDefaults,
|
||||
XMLBagElement collection,
|
||||
Map<String, MetaAttribute> entityMetaAttributes) {
|
||||
BindingContext bindingContext,
|
||||
MetaAttributeContext parentMetaAttributeContext,
|
||||
XMLBagElement collection) {
|
||||
super(
|
||||
ownerClassName,
|
||||
collection.getName(),
|
||||
mappingDefaults,
|
||||
bindingContext,
|
||||
collection.getNode(),
|
||||
HbmHelper.extractMetas( collection.getMeta(), entityMetaAttributes ),
|
||||
HbmHelper.extractMetaAttributeContext( collection.getMeta(), parentMetaAttributeContext ),
|
||||
HbmHelper.getPropertyAccessorName(
|
||||
collection.getAccess(), collection.isEmbedXml(), mappingDefaults.getDefaultAccess()
|
||||
collection.getAccess(), collection.isEmbedXml(), bindingContext.getMappingDefaults().getDefaultAccess()
|
||||
),
|
||||
collection.isOptimisticLock()
|
||||
);
|
||||
this.collection = collection;
|
||||
this.collectionPersisterClass = MappingHelper.classForName(
|
||||
collection.getPersister(), getDefaults().getServiceRegistry()
|
||||
collection.getPersister(), getBindingContext().getServiceRegistry()
|
||||
);
|
||||
this.cascadeTypes = determineCascadeTypes( collection.getCascade() );
|
||||
|
||||
|
@ -117,7 +116,9 @@ public class HbmPluralAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
|
||||
public boolean isLazy() {
|
||||
return isExtraLazy() ||
|
||||
MappingHelper.getBooleanValue( collection.getLazy().value(), getDefaults().isDefaultLazy() );
|
||||
MappingHelper.getBooleanValue(
|
||||
collection.getLazy().value(), getBindingContext().getMappingDefaults().isDefaultLazy()
|
||||
);
|
||||
}
|
||||
|
||||
public boolean isExtraLazy() {
|
||||
|
|
|
@ -31,15 +31,16 @@ import org.hibernate.MappingException;
|
|||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.binding.CascadeType;
|
||||
import org.hibernate.metamodel.binding.state.SimpleAttributeBindingState;
|
||||
import org.hibernate.metamodel.domain.MetaAttribute;
|
||||
import org.hibernate.metamodel.source.hbm.HbmHelper;
|
||||
import org.hibernate.metamodel.source.hbm.MappingDefaults;
|
||||
import org.hibernate.metamodel.source.hbm.util.MappingHelper;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLClass.XMLId;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLClass.XMLTimestamp;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLClass.XMLVersion;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLParamElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLPropertyElement;
|
||||
import org.hibernate.metamodel.source.spi.BindingContext;
|
||||
import org.hibernate.metamodel.source.spi.MappingDefaults;
|
||||
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
|
@ -56,25 +57,25 @@ public class HbmSimpleAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
|
||||
public HbmSimpleAttributeBindingState(
|
||||
String ownerClassName,
|
||||
MappingDefaults defaults,
|
||||
Map<String, MetaAttribute> entityMetaAttributes,
|
||||
BindingContext bindingContext,
|
||||
MetaAttributeContext parentMetaAttributeContext,
|
||||
XMLId id) {
|
||||
super(
|
||||
ownerClassName,
|
||||
id.getName() != null ? id.getName() : defaults.getDefaultIdColumnName(),
|
||||
defaults,
|
||||
id.getName() != null ? id.getName() : bindingContext.getMappingDefaults().getDefaultIdColumnName(),
|
||||
bindingContext,
|
||||
id.getNode(),
|
||||
HbmHelper.extractMetas( id.getMeta(), entityMetaAttributes ),
|
||||
HbmHelper.getPropertyAccessorName( id.getAccess(), false, defaults.getDefaultAccess() ),
|
||||
HbmHelper.extractMetaAttributeContext( id.getMeta(), parentMetaAttributeContext ),
|
||||
HbmHelper.getPropertyAccessorName( id.getAccess(), false, bindingContext.getMappingDefaults().getDefaultAccess() ),
|
||||
true
|
||||
);
|
||||
|
||||
this.isLazy = false;
|
||||
if ( id.getTypeAttribute() != null ) {
|
||||
typeName = maybeConvertToTypeDefName( id.getTypeAttribute(), defaults );
|
||||
typeName = maybeConvertToTypeDefName( id.getTypeAttribute(), bindingContext.getMappingDefaults() );
|
||||
}
|
||||
else if ( id.getType() != null ) {
|
||||
typeName = maybeConvertToTypeDefName( id.getType().getName(), defaults );
|
||||
typeName = maybeConvertToTypeDefName( id.getType().getName(), bindingContext.getMappingDefaults() );
|
||||
}
|
||||
else {
|
||||
typeName = getTypeNameByReflection();
|
||||
|
@ -99,16 +100,16 @@ public class HbmSimpleAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
|
||||
public HbmSimpleAttributeBindingState(
|
||||
String ownerClassName,
|
||||
MappingDefaults defaults,
|
||||
Map<String, MetaAttribute> entityMetaAttributes,
|
||||
BindingContext bindingContext,
|
||||
MetaAttributeContext parentMetaAttributeContext,
|
||||
XMLVersion version) {
|
||||
super(
|
||||
ownerClassName,
|
||||
version.getName(),
|
||||
defaults,
|
||||
bindingContext,
|
||||
version.getNode(),
|
||||
HbmHelper.extractMetas( version.getMeta(), entityMetaAttributes ),
|
||||
HbmHelper.getPropertyAccessorName( version.getAccess(), false, defaults.getDefaultAccess() ),
|
||||
HbmHelper.extractMetaAttributeContext( version.getMeta(), parentMetaAttributeContext ),
|
||||
HbmHelper.getPropertyAccessorName( version.getAccess(), false, bindingContext.getMappingDefaults().getDefaultAccess() ),
|
||||
true
|
||||
);
|
||||
this.typeName = version.getType() == null ? "integer" : version.getType();
|
||||
|
@ -128,17 +129,17 @@ public class HbmSimpleAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
|
||||
public HbmSimpleAttributeBindingState(
|
||||
String ownerClassName,
|
||||
MappingDefaults defaults,
|
||||
Map<String, MetaAttribute> entityMetaAttributes,
|
||||
BindingContext bindingContext,
|
||||
MetaAttributeContext parentMetaAttributeContext,
|
||||
XMLTimestamp timestamp) {
|
||||
|
||||
super(
|
||||
ownerClassName,
|
||||
timestamp.getName(),
|
||||
defaults,
|
||||
bindingContext,
|
||||
timestamp.getNode(),
|
||||
HbmHelper.extractMetas( timestamp.getMeta(), entityMetaAttributes ),
|
||||
HbmHelper.getPropertyAccessorName( timestamp.getAccess(), false, defaults.getDefaultAccess() ),
|
||||
HbmHelper.extractMetaAttributeContext( timestamp.getMeta(), parentMetaAttributeContext ),
|
||||
HbmHelper.getPropertyAccessorName( timestamp.getAccess(), false, bindingContext.getMappingDefaults().getDefaultAccess() ),
|
||||
true
|
||||
);
|
||||
|
||||
|
@ -159,16 +160,16 @@ public class HbmSimpleAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
|
||||
public HbmSimpleAttributeBindingState(
|
||||
String ownerClassName,
|
||||
MappingDefaults defaults,
|
||||
Map<String, MetaAttribute> entityMetaAttributes,
|
||||
BindingContext bindingContext,
|
||||
MetaAttributeContext parentMetaAttributeContext,
|
||||
XMLPropertyElement property) {
|
||||
super(
|
||||
ownerClassName,
|
||||
property.getName(),
|
||||
defaults,
|
||||
bindingContext,
|
||||
property.getNode(),
|
||||
HbmHelper.extractMetas( property.getMeta(), entityMetaAttributes ),
|
||||
HbmHelper.getPropertyAccessorName( property.getAccess(), false, defaults.getDefaultAccess() ),
|
||||
HbmHelper.extractMetaAttributeContext( property.getMeta(), parentMetaAttributeContext ),
|
||||
HbmHelper.getPropertyAccessorName( property.getAccess(), false, bindingContext.getMappingDefaults().getDefaultAccess() ),
|
||||
property.isOptimisticLock()
|
||||
);
|
||||
this.isLazy = property.isLazy();
|
||||
|
@ -206,10 +207,10 @@ public class HbmSimpleAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
}
|
||||
|
||||
if ( property.getTypeAttribute() != null ) {
|
||||
typeName = maybeConvertToTypeDefName( property.getTypeAttribute(), defaults );
|
||||
typeName = maybeConvertToTypeDefName( property.getTypeAttribute(), bindingContext.getMappingDefaults() );
|
||||
}
|
||||
else if ( property.getType() != null ) {
|
||||
typeName = maybeConvertToTypeDefName( property.getType().getName(), defaults );
|
||||
typeName = maybeConvertToTypeDefName( property.getType().getName(), bindingContext.getMappingDefaults() );
|
||||
for ( XMLParamElement typeParameter : property.getType().getParam() ) {
|
||||
//TODO: add parameters from typedef
|
||||
typeParameters.put( typeParameter.getName(), typeParameter.getValue().trim() );
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.source.hbm.state.relational;
|
||||
|
||||
import org.hibernate.metamodel.source.hbm.MappingDefaults;
|
||||
import org.hibernate.metamodel.relational.state.ManyToOneRelationalState;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLManyToOneElement;
|
||||
import org.hibernate.metamodel.source.spi.BindingContext;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
|
@ -36,10 +36,11 @@ implements ManyToOneRelationalState {
|
|||
private final boolean isLogicalOneToOne;
|
||||
private final String foreignKeyName;
|
||||
|
||||
public HbmManyToOneRelationalStateContainer(MappingDefaults defaults,
|
||||
boolean autoColumnCreation,
|
||||
XMLManyToOneElement manyToOne ) {
|
||||
super( defaults, autoColumnCreation, manyToOne );
|
||||
public HbmManyToOneRelationalStateContainer(
|
||||
BindingContext bindingContext,
|
||||
boolean autoColumnCreation,
|
||||
XMLManyToOneElement manyToOne ) {
|
||||
super( bindingContext, autoColumnCreation, manyToOne );
|
||||
this.isLogicalOneToOne = manyToOne.isUnique();
|
||||
this.foreignKeyName = manyToOne.getForeignKey();
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import java.util.Set;
|
|||
import org.hibernate.MappingException;
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.metamodel.binding.HibernateTypeDescriptor;
|
||||
import org.hibernate.metamodel.source.hbm.MappingDefaults;
|
||||
import org.hibernate.metamodel.relational.state.SimpleValueRelationalState;
|
||||
import org.hibernate.metamodel.relational.state.TupleRelationalState;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLColumnElement;
|
||||
|
@ -41,27 +40,33 @@ import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLCla
|
|||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLClass.XMLVersion;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLManyToOneElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLPropertyElement;
|
||||
import org.hibernate.metamodel.source.spi.BindingContext;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class HbmSimpleValueRelationalStateContainer implements TupleRelationalState {
|
||||
private final MappingDefaults defaults;
|
||||
private final BindingContext bindingContext;
|
||||
private final Set<String> propertyUniqueKeys;
|
||||
private final Set<String> propertyIndexes;
|
||||
private final List<SimpleValueRelationalState> simpleValueStates;
|
||||
private final HibernateTypeDescriptor hibernateTypeDescriptor = new HibernateTypeDescriptor();
|
||||
|
||||
public BindingContext getBindingContext() {
|
||||
return bindingContext;
|
||||
}
|
||||
|
||||
public NamingStrategy getNamingStrategy() {
|
||||
return defaults.getNamingStrategy();
|
||||
return getBindingContext().getNamingStrategy();
|
||||
}
|
||||
|
||||
// TODO: remove duplication after Id, Discriminator, Version, Timestamp, and Property extend a common interface.
|
||||
|
||||
public HbmSimpleValueRelationalStateContainer(MappingDefaults defaults,
|
||||
boolean autoColumnCreation,
|
||||
XMLId id) {
|
||||
this( defaults, id.getColumn() );
|
||||
public HbmSimpleValueRelationalStateContainer(
|
||||
BindingContext bindingContext,
|
||||
boolean autoColumnCreation,
|
||||
XMLId id) {
|
||||
this( bindingContext, id.getColumn() );
|
||||
if ( simpleValueStates.isEmpty() ) {
|
||||
if ( id.getColumn() == null && ! autoColumnCreation ) {
|
||||
throw new MappingException( "No columns to map and auto column creation is disabled." );
|
||||
|
@ -74,10 +79,11 @@ public class HbmSimpleValueRelationalStateContainer implements TupleRelationalSt
|
|||
this.hibernateTypeDescriptor.setTypeName( id.getTypeAttribute() );
|
||||
}
|
||||
|
||||
public HbmSimpleValueRelationalStateContainer(MappingDefaults defaults,
|
||||
boolean autoColumnCreation,
|
||||
XMLDiscriminator discriminator) {
|
||||
this( defaults, discriminator.getFormula(), discriminator.getColumn() );
|
||||
public HbmSimpleValueRelationalStateContainer(
|
||||
BindingContext bindingContext,
|
||||
boolean autoColumnCreation,
|
||||
XMLDiscriminator discriminator) {
|
||||
this( bindingContext, discriminator.getFormula(), discriminator.getColumn() );
|
||||
if ( simpleValueStates.isEmpty() ) {
|
||||
if ( discriminator.getColumn() == null && discriminator.getFormula() == null && ! autoColumnCreation ) {
|
||||
throw new MappingException( "No column or formula to map and auto column creation is disabled." );
|
||||
|
@ -90,10 +96,11 @@ public class HbmSimpleValueRelationalStateContainer implements TupleRelationalSt
|
|||
this.hibernateTypeDescriptor.setTypeName( discriminator.getType() == null ? "string" : discriminator.getType() );
|
||||
}
|
||||
|
||||
public HbmSimpleValueRelationalStateContainer(MappingDefaults defaults,
|
||||
boolean autoColumnCreation,
|
||||
XMLVersion version) {
|
||||
this( defaults, version.getColumn() );
|
||||
public HbmSimpleValueRelationalStateContainer(
|
||||
BindingContext bindingContext,
|
||||
boolean autoColumnCreation,
|
||||
XMLVersion version) {
|
||||
this( bindingContext, version.getColumn() );
|
||||
if ( simpleValueStates.isEmpty() ) {
|
||||
if ( version.getColumn() == null && ! autoColumnCreation ) {
|
||||
throw new MappingException( "No column or formula to map and auto column creation is disabled." );
|
||||
|
@ -106,10 +113,11 @@ public class HbmSimpleValueRelationalStateContainer implements TupleRelationalSt
|
|||
this.hibernateTypeDescriptor.setTypeName( version.getType() == null ? "integer" : version.getType() );
|
||||
}
|
||||
|
||||
public HbmSimpleValueRelationalStateContainer(MappingDefaults defaults,
|
||||
boolean autoColumnCreation,
|
||||
XMLTimestamp timestamp) {
|
||||
this( defaults, null );
|
||||
public HbmSimpleValueRelationalStateContainer(
|
||||
BindingContext bindingContext,
|
||||
boolean autoColumnCreation,
|
||||
XMLTimestamp timestamp) {
|
||||
this( bindingContext, null );
|
||||
if ( simpleValueStates.isEmpty() ) {
|
||||
if ( timestamp.getColumn() == null && ! autoColumnCreation ) {
|
||||
throw new MappingException( "No columns to map and auto column creation is disabled." );
|
||||
|
@ -122,10 +130,11 @@ public class HbmSimpleValueRelationalStateContainer implements TupleRelationalSt
|
|||
this.hibernateTypeDescriptor.setTypeName( "db".equals( timestamp.getSource() ) ? "dbtimestamp" : "timestamp" );
|
||||
}
|
||||
|
||||
public HbmSimpleValueRelationalStateContainer(MappingDefaults defaults,
|
||||
boolean autoColumnCreation,
|
||||
XMLPropertyElement property) {
|
||||
this( defaults, property.getColumnOrFormula() );
|
||||
public HbmSimpleValueRelationalStateContainer(
|
||||
BindingContext bindingContext,
|
||||
boolean autoColumnCreation,
|
||||
XMLPropertyElement property) {
|
||||
this( bindingContext, property.getColumnOrFormula() );
|
||||
if ( simpleValueStates.isEmpty() ) {
|
||||
if ( property.getColumn() == null && property.getFormula() == null && ! autoColumnCreation ) {
|
||||
throw new MappingException( "No column or formula to map and auto column creation is disabled." );
|
||||
|
@ -138,10 +147,11 @@ public class HbmSimpleValueRelationalStateContainer implements TupleRelationalSt
|
|||
this.hibernateTypeDescriptor.setTypeName( property.getTypeAttribute() );
|
||||
}
|
||||
|
||||
public HbmSimpleValueRelationalStateContainer(MappingDefaults defaults,
|
||||
boolean autoColumnCreation,
|
||||
XMLManyToOneElement manyToOne) {
|
||||
this( defaults, manyToOne.getColumnOrFormula() );
|
||||
public HbmSimpleValueRelationalStateContainer(
|
||||
BindingContext bindingContext,
|
||||
boolean autoColumnCreation,
|
||||
XMLManyToOneElement manyToOne) {
|
||||
this( bindingContext, manyToOne.getColumnOrFormula() );
|
||||
if ( simpleValueStates.isEmpty() ) {
|
||||
if ( manyToOne.getColumn() == null && manyToOne.getFormula() == null && ! autoColumnCreation ) {
|
||||
throw new MappingException( "No column or formula to map and auto column creation is disabled." );
|
||||
|
@ -153,26 +163,29 @@ public class HbmSimpleValueRelationalStateContainer implements TupleRelationalSt
|
|||
}
|
||||
}
|
||||
|
||||
private HbmSimpleValueRelationalStateContainer(MappingDefaults defaults,
|
||||
String formulaElement,
|
||||
XMLColumnElement columnElement
|
||||
) {
|
||||
this( defaults,
|
||||
formulaElement != null ?
|
||||
Collections.singletonList( formulaElement ) :
|
||||
columnElement != null ? Collections.singletonList( columnElement ) : Collections.<Object>emptyList()
|
||||
private HbmSimpleValueRelationalStateContainer(
|
||||
BindingContext bindingContext,
|
||||
String formulaElement,
|
||||
XMLColumnElement columnElement) {
|
||||
this( bindingContext,
|
||||
formulaElement != null
|
||||
? Collections.singletonList( formulaElement )
|
||||
: columnElement != null
|
||||
? Collections.singletonList( columnElement )
|
||||
: Collections.<Object>emptyList()
|
||||
);
|
||||
}
|
||||
|
||||
private HbmSimpleValueRelationalStateContainer(MappingDefaults defaults,
|
||||
List mappedColumnsOrFormulas) {
|
||||
this.defaults = defaults;
|
||||
private HbmSimpleValueRelationalStateContainer(
|
||||
BindingContext bindingContext,
|
||||
List mappedColumnsOrFormulas) {
|
||||
this.bindingContext = bindingContext;
|
||||
this.propertyUniqueKeys = Collections.emptySet();
|
||||
this.propertyIndexes = Collections.emptySet();
|
||||
simpleValueStates = new ArrayList<SimpleValueRelationalState>(
|
||||
mappedColumnsOrFormulas == null || mappedColumnsOrFormulas.isEmpty() ?
|
||||
1 :
|
||||
mappedColumnsOrFormulas.size()
|
||||
mappedColumnsOrFormulas == null || mappedColumnsOrFormulas.isEmpty()
|
||||
? 1
|
||||
: mappedColumnsOrFormulas.size()
|
||||
);
|
||||
if ( mappedColumnsOrFormulas != null && ! mappedColumnsOrFormulas.isEmpty() ) {
|
||||
for ( Object mappedColumnOrFormula : mappedColumnsOrFormulas ) {
|
||||
|
|
|
@ -89,6 +89,8 @@ public class MetadataBuilderImpl implements MetadataBuilder {
|
|||
private SharedCacheMode sharedCacheMode = SharedCacheMode.ENABLE_SELECTIVE;
|
||||
private AccessType defaultCacheAccessType;
|
||||
private boolean useNewIdentifierGenerators;
|
||||
private String defaultSchemaName;
|
||||
private String defaultCatalogName;
|
||||
|
||||
public OptionsImpl(BasicServiceRegistry serviceRegistry) {
|
||||
ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class );
|
||||
|
@ -114,6 +116,28 @@ public class MetadataBuilderImpl implements MetadataBuilder {
|
|||
},
|
||||
false
|
||||
);
|
||||
|
||||
defaultSchemaName = configService.getSetting(
|
||||
AvailableSettings.DEFAULT_SCHEMA,
|
||||
new ConfigurationService.Converter<String>() {
|
||||
@Override
|
||||
public String convert(Object value) {
|
||||
return value.toString();
|
||||
}
|
||||
},
|
||||
null
|
||||
);
|
||||
|
||||
defaultCatalogName = configService.getSetting(
|
||||
AvailableSettings.DEFAULT_CATALOG,
|
||||
new ConfigurationService.Converter<String>() {
|
||||
@Override
|
||||
public String convert(Object value) {
|
||||
return value.toString();
|
||||
}
|
||||
},
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -141,5 +165,15 @@ public class MetadataBuilderImpl implements MetadataBuilder {
|
|||
public boolean useNewIdentifierGenerators() {
|
||||
return useNewIdentifierGenerators;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultSchemaName() {
|
||||
return defaultSchemaName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultCatalogName() {
|
||||
return defaultCatalogName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.jboss.logging.Logger;
|
|||
import org.hibernate.DuplicateMappingException;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.engine.spi.FilterDefinition;
|
||||
import org.hibernate.engine.spi.NamedQueryDefinition;
|
||||
import org.hibernate.engine.spi.NamedSQLQueryDefinition;
|
||||
|
@ -59,8 +60,12 @@ import org.hibernate.metamodel.source.annotations.AnnotationBinder;
|
|||
import org.hibernate.metamodel.source.annotations.xml.OrmXmlParser;
|
||||
import org.hibernate.metamodel.source.hbm.HbmBinder;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping;
|
||||
import org.hibernate.metamodel.source.spi.BindingContext;
|
||||
import org.hibernate.metamodel.source.spi.MappingDefaults;
|
||||
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
|
||||
import org.hibernate.metamodel.source.spi.MetadataImplementor;
|
||||
import org.hibernate.service.BasicServiceRegistry;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.type.TypeResolver;
|
||||
|
||||
|
@ -86,6 +91,8 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
|
||||
private final Database database = new Database();
|
||||
|
||||
private final MappingDefaults mappingDefaults;
|
||||
|
||||
/**
|
||||
* Maps the fully qualified class name of an entity to its entity binding
|
||||
*/
|
||||
|
@ -106,6 +113,9 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
this.serviceRegistry = metadataSources.getServiceRegistry();
|
||||
this.options = options;
|
||||
|
||||
this.mappingDefaults = new MappingDefaultsImpl();
|
||||
|
||||
applyIndependentMetadata();
|
||||
final ArrayList<String> processedEntityNames = new ArrayList<String>();
|
||||
if ( options.getSourceProcessingOrder() == SourceProcessingOrder.HBM_FIRST ) {
|
||||
applyHibernateMappings( metadataSources, processedEntityNames );
|
||||
|
@ -119,6 +129,10 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
new EntityReferenceResolver( this ).resolve();
|
||||
}
|
||||
|
||||
private void applyIndependentMetadata() {
|
||||
// todo : implement method body
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFetchProfile(FetchProfile profile) {
|
||||
fetchProfiles.put( profile.getName(), profile );
|
||||
|
@ -193,12 +207,11 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
}
|
||||
|
||||
private void applyHibernateMappings(MetadataSources metadataSources, List<String> processedEntityNames) {
|
||||
|
||||
for ( JaxbRoot jaxbRoot : metadataSources.getJaxbRootList() ) {
|
||||
// filter to just hbm-based roots
|
||||
if ( jaxbRoot.getRoot() instanceof XMLHibernateMapping ) {
|
||||
final HbmBinder mappingBinder = new HbmBinder(
|
||||
this, Collections.<String, MetaAttribute>emptyMap(), jaxbRoot
|
||||
);
|
||||
final HbmBinder mappingBinder = new HbmBinder( this, jaxbRoot );
|
||||
mappingBinder.processHibernateMapping();
|
||||
}
|
||||
}
|
||||
|
@ -331,4 +344,79 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
public TypeResolver getTypeResolver() {
|
||||
return typeResolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamingStrategy getNamingStrategy() {
|
||||
return options.getNamingStrategy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MappingDefaults getMappingDefaults() {
|
||||
return mappingDefaults;
|
||||
}
|
||||
|
||||
private final MetaAttributeContext globalMetaAttributeContext = new MetaAttributeContext();
|
||||
|
||||
@Override
|
||||
public MetaAttributeContext getMetaAttributeContext() {
|
||||
return globalMetaAttributeContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataImplementor getMetadataImplementor() {
|
||||
return this;
|
||||
}
|
||||
|
||||
private static final String DEFAULT_IDENTIFIER_COLUMN_NAME = "id";
|
||||
private static final String DEFAULT_DISCRIMINATOR_COLUMN_NAME = "class";
|
||||
private static final String DEFAULT_CASCADE = "none";
|
||||
private static final String DEFAULT_PROPERTY_ACCESS = "property";
|
||||
|
||||
private class MappingDefaultsImpl implements MappingDefaults {
|
||||
|
||||
@Override
|
||||
public String getPackageName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultSchemaName() {
|
||||
return options.getDefaultSchemaName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultCatalogName() {
|
||||
return options.getDefaultCatalogName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultIdColumnName() {
|
||||
return DEFAULT_IDENTIFIER_COLUMN_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultDiscriminatorColumnName() {
|
||||
return DEFAULT_DISCRIMINATOR_COLUMN_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultCascade() {
|
||||
return DEFAULT_CASCADE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultAccess() {
|
||||
return DEFAULT_PROPERTY_ACCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefaultLazy() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, MetaAttribute> getMappingMetas() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2011, Red Hat Inc. 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 Inc.
|
||||
*
|
||||
* 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.hibernate.metamodel.source.internal;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.metamodel.domain.MetaAttribute;
|
||||
import org.hibernate.metamodel.source.spi.MappingDefaults;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class OverriddenMappingDefaults implements MappingDefaults {
|
||||
private MappingDefaults overriddenValues;
|
||||
|
||||
private final String packageName;
|
||||
private final String schemaName;
|
||||
private final String catalogName;
|
||||
private final String idColumnName;
|
||||
private final String discriminatorColumnName;
|
||||
private final String cascade;
|
||||
private final String propertyAccess;
|
||||
private final Boolean associationLaziness;
|
||||
|
||||
public OverriddenMappingDefaults(
|
||||
MappingDefaults overriddenValues,
|
||||
String packageName,
|
||||
String schemaName,
|
||||
String catalogName,
|
||||
String idColumnName,
|
||||
String discriminatorColumnName,
|
||||
String cascade,
|
||||
String propertyAccess,
|
||||
Boolean associationLaziness) {
|
||||
if ( overriddenValues == null ) {
|
||||
throw new IllegalArgumentException( "Overridden values cannot be null" );
|
||||
}
|
||||
this.overriddenValues = overriddenValues;
|
||||
this.packageName = packageName;
|
||||
this.schemaName = schemaName;
|
||||
this.catalogName = catalogName;
|
||||
this.idColumnName = idColumnName;
|
||||
this.discriminatorColumnName = discriminatorColumnName;
|
||||
this.cascade = cascade;
|
||||
this.propertyAccess = propertyAccess;
|
||||
this.associationLaziness = associationLaziness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPackageName() {
|
||||
return packageName == null ? overriddenValues.getPackageName() : packageName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultSchemaName() {
|
||||
return schemaName == null ? overriddenValues.getDefaultSchemaName() : schemaName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultCatalogName() {
|
||||
return catalogName == null ? overriddenValues.getDefaultCatalogName() : catalogName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultIdColumnName() {
|
||||
return idColumnName == null ? overriddenValues.getDefaultIdColumnName() : idColumnName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultDiscriminatorColumnName() {
|
||||
return discriminatorColumnName == null ? overriddenValues.getDefaultDiscriminatorColumnName() : discriminatorColumnName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultCascade() {
|
||||
return cascade == null ? overriddenValues.getDefaultCascade() : cascade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultAccess() {
|
||||
return propertyAccess == null ? overriddenValues.getDefaultAccess() : propertyAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefaultLazy() {
|
||||
return associationLaziness == null ? overriddenValues.isDefaultLazy() : associationLaziness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, MetaAttribute> getMappingMetas() {
|
||||
return null; // todo : implement method body
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2011, Red Hat Inc. 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 Inc.
|
||||
*
|
||||
* 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.hibernate.metamodel.source.internal;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.metamodel.domain.MetaAttribute;
|
||||
import org.hibernate.metamodel.source.spi.MappingDefaults;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class RootMappingDefaults implements MappingDefaults {
|
||||
private final String packageName;
|
||||
private final String schemaName;
|
||||
private final String catalogName;
|
||||
private final String idColumnName;
|
||||
private final String discriminatorColumnName;
|
||||
private final String cascade;
|
||||
private final String propertyAccess;
|
||||
private final boolean associationLaziness;
|
||||
|
||||
public RootMappingDefaults(
|
||||
String packageName,
|
||||
String schemaName,
|
||||
String catalogName,
|
||||
String idColumnName,
|
||||
String discriminatorColumnName,
|
||||
String cascade,
|
||||
String propertyAccess,
|
||||
boolean associationLaziness) {
|
||||
this.packageName = packageName;
|
||||
this.schemaName = schemaName;
|
||||
this.catalogName = catalogName;
|
||||
this.idColumnName = idColumnName;
|
||||
this.discriminatorColumnName = discriminatorColumnName;
|
||||
this.cascade = cascade;
|
||||
this.propertyAccess = propertyAccess;
|
||||
this.associationLaziness = associationLaziness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultSchemaName() {
|
||||
return schemaName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultCatalogName() {
|
||||
return catalogName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultIdColumnName() {
|
||||
return idColumnName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultDiscriminatorColumnName() {
|
||||
return discriminatorColumnName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultCascade() {
|
||||
return cascade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultAccess() {
|
||||
return propertyAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefaultLazy() {
|
||||
return associationLaziness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, MetaAttribute> getMappingMetas() {
|
||||
return null; // todo : implement method body
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2011, Red Hat Inc. 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 Inc.
|
||||
*
|
||||
* 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.hibernate.metamodel.source.spi;
|
||||
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface BindingContext {
|
||||
public ServiceRegistry getServiceRegistry();
|
||||
|
||||
public NamingStrategy getNamingStrategy();
|
||||
|
||||
public MappingDefaults getMappingDefaults();
|
||||
|
||||
public MetaAttributeContext getMetaAttributeContext();
|
||||
|
||||
public MetadataImplementor getMetadataImplementor();
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.hbm;
|
||||
package org.hibernate.metamodel.source.spi;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -31,9 +31,9 @@ import org.hibernate.service.ServiceRegistry;
|
|||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface MappingDefaults {
|
||||
Map<String, MetaAttribute> getMappingMetas();
|
||||
|
||||
String getPackageName();
|
||||
|
||||
|
@ -51,7 +51,8 @@ public interface MappingDefaults {
|
|||
|
||||
boolean isDefaultLazy();
|
||||
|
||||
ServiceRegistry getServiceRegistry();
|
||||
|
||||
NamingStrategy getNamingStrategy();
|
||||
// Not happy about these here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Map<String, MetaAttribute> getMappingMetas();
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2011, Red Hat Inc. 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 Inc.
|
||||
*
|
||||
* 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.hibernate.metamodel.source.spi;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.hibernate.metamodel.domain.MetaAttribute;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class MetaAttributeContext {
|
||||
private final MetaAttributeContext parentContext;
|
||||
private final ConcurrentHashMap<String, MetaAttribute> metaAttributeMap = new ConcurrentHashMap<String, MetaAttribute>();
|
||||
|
||||
public MetaAttributeContext() {
|
||||
this( null );
|
||||
}
|
||||
|
||||
public MetaAttributeContext(MetaAttributeContext parentContext) {
|
||||
this.parentContext = parentContext;
|
||||
}
|
||||
|
||||
|
||||
// read contract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
public Iterable<String> getKeys() {
|
||||
HashSet<String> keys = new HashSet<String>();
|
||||
addKeys( keys );
|
||||
return keys;
|
||||
}
|
||||
|
||||
private void addKeys(Set<String> keys) {
|
||||
keys.addAll( metaAttributeMap.keySet() );
|
||||
if ( parentContext != null ) {
|
||||
// recursive call
|
||||
parentContext.addKeys( keys );
|
||||
}
|
||||
}
|
||||
|
||||
public Iterable<String> getLocalKeys() {
|
||||
return metaAttributeMap.keySet();
|
||||
}
|
||||
|
||||
public MetaAttribute getMetaAttribute(String key) {
|
||||
MetaAttribute value = getLocalMetaAttribute( key );
|
||||
if ( value == null ) {
|
||||
// recursive call
|
||||
value = parentContext.getMetaAttribute( key );
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public MetaAttribute getLocalMetaAttribute(String key) {
|
||||
return metaAttributeMap.get( key );
|
||||
}
|
||||
|
||||
|
||||
// write contract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
public void add(MetaAttribute metaAttribute) {
|
||||
metaAttributeMap.put( metaAttribute.getName(), metaAttribute );
|
||||
}
|
||||
|
||||
}
|
|
@ -27,7 +27,6 @@ import org.hibernate.engine.spi.FilterDefinition;
|
|||
import org.hibernate.metamodel.Metadata;
|
||||
import org.hibernate.metamodel.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.binding.FetchProfile;
|
||||
import org.hibernate.metamodel.binding.IdGenerator;
|
||||
import org.hibernate.metamodel.binding.PluralAttributeBinding;
|
||||
import org.hibernate.metamodel.binding.TypeDef;
|
||||
import org.hibernate.metamodel.relational.AuxiliaryDatabaseObject;
|
||||
|
@ -38,15 +37,11 @@ import org.hibernate.type.TypeResolver;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface MetadataImplementor extends Metadata {
|
||||
public interface MetadataImplementor extends Metadata, BindingContext {
|
||||
public BasicServiceRegistry getServiceRegistry();
|
||||
|
||||
public Database getDatabase();
|
||||
|
||||
public Iterable<EntityBinding> getEntityBindings();
|
||||
|
||||
public EntityBinding getEntityBinding(String entityName);
|
||||
|
||||
public TypeResolver getTypeResolver();
|
||||
|
||||
public void addImport(String entityName, String entityName1);
|
||||
|
@ -59,15 +54,9 @@ public interface MetadataImplementor extends Metadata {
|
|||
|
||||
public void addTypeDefinition(TypeDef typeDef);
|
||||
|
||||
public Iterable<TypeDef> getTypeDefinitions();
|
||||
|
||||
public void addFilterDefinition(FilterDefinition filterDefinition);
|
||||
|
||||
public Iterable<FilterDefinition> getFilterDefinitions();
|
||||
|
||||
public void registerIdentifierGenerator(String name, String clazz);
|
||||
|
||||
public IdGenerator getIdGenerator(String name);
|
||||
|
||||
public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue