HHH-6371 - Develop metamodel binding creation using a push approach
This commit is contained in:
parent
182150769a
commit
5efd0a8471
|
@ -12,6 +12,7 @@ allprojects {
|
|||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
mavenRepo name: 'jboss-nexus', urls: "https://repository.jboss.org/nexus/content/groups/public/"
|
||||
mavenRepo name: "jboss-snapshots", urls: "http://snapshots.jboss.org/maven2/"
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.hibernate.metamodel.source.Origin;
|
|||
import org.hibernate.metamodel.source.hbm.HbmBindingContext;
|
||||
import org.hibernate.metamodel.source.hbm.HbmHelper;
|
||||
import org.hibernate.metamodel.source.hbm.util.MappingHelper;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.EntityElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLCacheElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlDeleteElement;
|
||||
|
@ -53,6 +54,8 @@ import org.hibernate.persister.entity.EntityPersister;
|
|||
import org.hibernate.tuple.entity.EntityTuplizer;
|
||||
|
||||
/**
|
||||
* TODO : thinking it might be better to have one of these for distinct mapping type (root, subclass, joined, etc)
|
||||
*
|
||||
* @author Gail Badner
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -102,7 +105,7 @@ public class EntityViewImpl implements EntityView {
|
|||
|
||||
public EntityViewImpl(
|
||||
Hierarchical superType,
|
||||
XMLHibernateMapping.XMLClass entityClazz,
|
||||
EntityElement entityClazz,
|
||||
boolean isRoot,
|
||||
InheritanceType inheritanceType,
|
||||
HbmBindingContext bindingContext) {
|
||||
|
@ -110,7 +113,7 @@ public class EntityViewImpl implements EntityView {
|
|||
this.bindingContext = bindingContext;
|
||||
|
||||
this.superType = superType;
|
||||
this.entityName = bindingContext.extractEntityName( entityClazz );
|
||||
this.entityName = bindingContext.determineEntityName( entityClazz );
|
||||
|
||||
final String verbatimClassName = entityClazz.getName();
|
||||
this.entityMode = verbatimClassName == null ? EntityMode.MAP : EntityMode.POJO;
|
||||
|
@ -135,7 +138,7 @@ public class EntityViewImpl implements EntityView {
|
|||
this.isRoot = isRoot;
|
||||
this.entityInheritanceType = inheritanceType;
|
||||
|
||||
this.caching = createCaching( entityClazz, bindingContext.extractEntityName( entityClazz ) );
|
||||
this.caching = isRoot ? createCaching( entityClazz, this.entityName ) : null;
|
||||
|
||||
this.metaAttributeContext = HbmHelper.extractMetaAttributeContext(
|
||||
entityClazz.getMeta(), true, bindingContext.getMetaAttributeContext()
|
||||
|
@ -215,11 +218,11 @@ public class EntityViewImpl implements EntityView {
|
|||
);
|
||||
}
|
||||
|
||||
private String extractCustomTuplizerClassName(XMLHibernateMapping.XMLClass entityClazz, EntityMode entityMode) {
|
||||
if ( entityClazz.getTuplizer() == null ) {
|
||||
private String extractCustomTuplizerClassName(EntityElement entityMapping, EntityMode entityMode) {
|
||||
if ( entityMapping.getTuplizer() == null ) {
|
||||
return null;
|
||||
}
|
||||
for ( XMLTuplizerElement tuplizerElement : entityClazz.getTuplizer() ) {
|
||||
for ( XMLTuplizerElement tuplizerElement : entityMapping.getTuplizer() ) {
|
||||
if ( entityMode == EntityMode.parse( tuplizerElement.getEntityMode() ) ) {
|
||||
return tuplizerElement.getClazz();
|
||||
}
|
||||
|
@ -227,8 +230,13 @@ public class EntityViewImpl implements EntityView {
|
|||
return null;
|
||||
}
|
||||
|
||||
private static Caching createCaching(XMLHibernateMapping.XMLClass entityClazz, String entityName) {
|
||||
XMLCacheElement cache = entityClazz.getCache();
|
||||
private static Caching createCaching(EntityElement entityMapping, String entityName) {
|
||||
if ( ! XMLHibernateMapping.XMLClass.class.isInstance( entityMapping ) ) {
|
||||
// only the root entity can define caching
|
||||
return null;
|
||||
}
|
||||
final XMLHibernateMapping.XMLClass rootEntityMapping = (XMLHibernateMapping.XMLClass) entityMapping;
|
||||
XMLCacheElement cache = rootEntityMapping.getCache();
|
||||
if ( cache == null ) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ abstract class AbstractEntityBinder {
|
|||
final String entityName = entityBinding.getEntity().getName();
|
||||
|
||||
if ( entityClazz.getFetchProfile() != null ) {
|
||||
bindingContext.bindFetchProfiles( entityClazz.getFetchProfile(), entityName );
|
||||
bindingContext.processFetchProfiles( entityClazz.getFetchProfile(), entityName );
|
||||
}
|
||||
|
||||
getMetadata().addImport( entityName, entityName );
|
||||
|
|
|
@ -26,12 +26,13 @@ package org.hibernate.metamodel.source.hbm;
|
|||
import org.hibernate.metamodel.binder.EntityBinder;
|
||||
import org.hibernate.metamodel.binder.view.hbm.EntityViewImpl;
|
||||
import org.hibernate.metamodel.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.EntityElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class EntityProcessor {
|
||||
public abstract class EntityProcessor {
|
||||
private final HbmBindingContext bindingContext;
|
||||
private final EntityBinder entityBinder;
|
||||
|
||||
|
@ -40,17 +41,17 @@ public class EntityProcessor {
|
|||
this.entityBinder = new EntityBinder( bindingContext.getMetadataImplementor() );
|
||||
}
|
||||
|
||||
public void process(XMLHibernateMapping.XMLClass xmlClass) {
|
||||
public void process(EntityElement entityMapping) {
|
||||
EntityBinding entityBinding = entityBinder.createEntityBinding(
|
||||
new EntityViewImpl(
|
||||
null, // superType
|
||||
xmlClass,
|
||||
entityMapping,
|
||||
true, // isRoot
|
||||
null, // inheritanceType
|
||||
bindingContext
|
||||
)
|
||||
);
|
||||
|
||||
bindingContext.
|
||||
bindingContext.getMetadataImplementor().addEntity( entityBinding );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ package org.hibernate.metamodel.source.hbm;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.internal.util.xml.XmlDocument;
|
||||
import org.hibernate.metamodel.source.Origin;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.EntityElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLFetchProfileElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping;
|
||||
import org.hibernate.metamodel.source.spi.BindingContext;
|
||||
|
@ -37,11 +37,12 @@ import org.hibernate.metamodel.source.spi.BindingContext;
|
|||
public interface HbmBindingContext extends BindingContext {
|
||||
public boolean isAutoImport();
|
||||
|
||||
public Origin getOrigin();
|
||||
|
||||
public String extractEntityName(XMLHibernateMapping.XMLClass entityClazz);
|
||||
public String determineEntityName(EntityElement entityElement);
|
||||
|
||||
public String getClassName(String unqualifiedName);
|
||||
|
||||
public void bindFetchProfiles(List<XMLFetchProfileElement> fetchProfiles, String containingEntityName);
|
||||
|
||||
public Origin getOrigin();
|
||||
public void processFetchProfiles(List<XMLFetchProfileElement> fetchProfiles, String containingEntityName);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.hibernate.MappingException;
|
|||
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
|
||||
import org.hibernate.metamodel.binding.CustomSQL;
|
||||
import org.hibernate.metamodel.binding.MetaAttribute;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.EntityElement;
|
||||
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;
|
||||
|
@ -102,6 +103,14 @@ public class HbmHelper {
|
|||
return entityName == null ? getClassName( entityClassName, unqualifiedPackageName ) : entityName;
|
||||
}
|
||||
|
||||
public static String determineEntityName(EntityElement entityElement, String packageName) {
|
||||
return extractEntityName( entityElement.getEntityName(), entityElement.getName(), packageName );
|
||||
}
|
||||
|
||||
public static String determineClassName(EntityElement entityElement, String packageName) {
|
||||
return getClassName( entityElement.getName(), packageName );
|
||||
}
|
||||
|
||||
public static String getClassName(Attribute att, String unqualifiedPackageName) {
|
||||
if ( att == null ) {
|
||||
return null;
|
||||
|
|
|
@ -24,13 +24,20 @@
|
|||
package org.hibernate.metamodel.source.hbm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.metamodel.MetadataSources;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.EntityElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.SubclassEntityElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping;
|
||||
import org.hibernate.metamodel.source.internal.JaxbRoot;
|
||||
import org.hibernate.metamodel.source.spi.SourceProcessor;
|
||||
import org.hibernate.metamodel.source.spi.MetadataImplementor;
|
||||
import org.hibernate.metamodel.source.spi.SourceProcessor;
|
||||
|
||||
/**
|
||||
* Responsible for performing binding of hbm xml.
|
||||
|
@ -57,28 +64,118 @@ public class HbmSourceProcessor implements SourceProcessor {
|
|||
@Override
|
||||
public void processIndependentMetadata(MetadataSources sources) {
|
||||
for ( HibernateMappingProcessor processor : processors ) {
|
||||
processor.bindIndependentMetadata();
|
||||
processor.processIndependentMetadata();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processTypeDependentMetadata(MetadataSources sources) {
|
||||
for ( HibernateMappingProcessor processor : processors ) {
|
||||
processor.bindTypeDependentMetadata();
|
||||
processor.processTypeDependentMetadata();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processMappingMetadata(MetadataSources sources, List<String> processedEntityNames) {
|
||||
// Lets get the entities into a better order for processing based on inheritance hierarchy to avoid the need
|
||||
// for an "extends queue". Really, for correctly, we localize the "extends queue" to just this method stack.
|
||||
//
|
||||
// The variable entityMappingByEntityNameMap holds the "resolved" mappings, keyed by entity name. It uses a
|
||||
// linked map because the order is important here as we will use it to track which entities depend on which
|
||||
// other entities.
|
||||
//
|
||||
// The extendsQueue variable is a temporary queue where we place mappings which have an extends but for which
|
||||
// we could not find the referenced entity being extended.
|
||||
|
||||
|
||||
|
||||
|
||||
final Set<String> availableEntityNames = new HashSet<String>();
|
||||
availableEntityNames.addAll( processedEntityNames );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
final LinkedHashSet<HibernateMappingProcessor> orderedProcessors = new LinkedHashSet<HibernateMappingProcessor>();
|
||||
final Set<ExtendsQueueEntry> extendsQueue = new HashSet<ExtendsQueueEntry>();
|
||||
|
||||
for ( HibernateMappingProcessor processor : processors ) {
|
||||
processor.bindMappingMetadata( processedEntityNames );
|
||||
final HibernateMappingInformation hibernateMappingInformation = new HibernateMappingInformation( processor );
|
||||
ExtendsQueueEntry extendsQueueEntry = null;
|
||||
for ( Object entityElementO : processor.getHibernateMapping().getClazzOrSubclassOrJoinedSubclass() ) {
|
||||
final EntityElement entityElement = (EntityElement) entityElementO;
|
||||
final String entityName = processor.determineEntityName( entityElement );
|
||||
hibernateMappingInformation.includedEntityNames.add( entityName );
|
||||
if ( SubclassEntityElement.class.isInstance( entityElement ) ) {
|
||||
final String entityItExtends = ( (SubclassEntityElement) entityElement ).getExtends();
|
||||
if ( ! availableEntityNames.contains( entityItExtends ) ) {
|
||||
if ( extendsQueueEntry == null ) {
|
||||
extendsQueueEntry = new ExtendsQueueEntry( hibernateMappingInformation );
|
||||
extendsQueue.add( extendsQueueEntry );
|
||||
}
|
||||
extendsQueueEntry.waitingOnEntityNames.add( entityItExtends );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( extendsQueueEntry == null ) {
|
||||
// we found no extends names that we have to wait on
|
||||
orderedProcessors.add( processor );
|
||||
availableEntityNames.addAll( hibernateMappingInformation.includedEntityNames );
|
||||
}
|
||||
}
|
||||
|
||||
while ( ! extendsQueue.isEmpty() ) {
|
||||
// set up a pass over the queue
|
||||
int numberOfMappingsProcessed = 0;
|
||||
Iterator<ExtendsQueueEntry> iterator = extendsQueue.iterator();
|
||||
while ( iterator.hasNext() ) {
|
||||
final ExtendsQueueEntry entry = iterator.next();
|
||||
if ( availableEntityNames.containsAll( entry.waitingOnEntityNames ) ) {
|
||||
// all the entity names this entry was waiting on have been made available
|
||||
iterator.remove();
|
||||
orderedProcessors.add( entry.hibernateMappingInformation.processor );
|
||||
availableEntityNames.addAll( entry.hibernateMappingInformation.includedEntityNames );
|
||||
numberOfMappingsProcessed++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( numberOfMappingsProcessed == 0 ) {
|
||||
// todo : we could log the waiting dependencies...
|
||||
throw new MappingException( "Unable to process extends dependencies in hbm files" );
|
||||
}
|
||||
}
|
||||
|
||||
for ( HibernateMappingProcessor processor : orderedProcessors ) {
|
||||
processor.processMappingMetadata( processedEntityNames );
|
||||
}
|
||||
}
|
||||
|
||||
private static class HibernateMappingInformation {
|
||||
private final HibernateMappingProcessor processor;
|
||||
private final Set<String> includedEntityNames = new HashSet<String>();
|
||||
|
||||
private HibernateMappingInformation(HibernateMappingProcessor processor) {
|
||||
this.processor = processor;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ExtendsQueueEntry {
|
||||
private HibernateMappingInformation hibernateMappingInformation;
|
||||
private final Set<String> waitingOnEntityNames = new HashSet<String>();
|
||||
|
||||
private ExtendsQueueEntry(HibernateMappingInformation hibernateMappingInformation) {
|
||||
this.hibernateMappingInformation = hibernateMappingInformation;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processMappingDependentMetadata(MetadataSources sources) {
|
||||
for ( HibernateMappingProcessor processor : processors ) {
|
||||
processor.bindMappingDependentMetadata();
|
||||
processor.processMappingDependentMetadata();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.util.Set;
|
|||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.engine.spi.FilterDefinition;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.Value;
|
||||
import org.hibernate.metamodel.binding.FetchProfile;
|
||||
import org.hibernate.metamodel.binding.TypeDef;
|
||||
import org.hibernate.metamodel.domain.JavaType;
|
||||
|
@ -39,6 +40,7 @@ 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.xml.mapping.EntityElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLFetchProfileElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLJoinedSubclassElement;
|
||||
|
@ -85,8 +87,8 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
hibernateMapping.getPackage(),
|
||||
hibernateMapping.getSchema(),
|
||||
hibernateMapping.getCatalog(),
|
||||
null,
|
||||
null,
|
||||
null, // idColumnName
|
||||
null, // discriminatorColumnName
|
||||
hibernateMapping.getDefaultCascade(),
|
||||
hibernateMapping.getDefaultAccess(),
|
||||
hibernateMapping.isDefaultLazy()
|
||||
|
@ -103,6 +105,10 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
: HbmHelper.extractMetaAttributeContext( hibernateMapping.getMeta(), true, metadata.getMetaAttributeContext() );
|
||||
}
|
||||
|
||||
XMLHibernateMapping getHibernateMapping() {
|
||||
return hibernateMapping;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoImport() {
|
||||
return autoImport;
|
||||
|
@ -153,12 +159,12 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
return metadata.makeJavaType( className );
|
||||
}
|
||||
|
||||
public void bindIndependentMetadata() {
|
||||
bindDatabaseObjectDefinitions();
|
||||
bindTypeDefinitions();
|
||||
public void processIndependentMetadata() {
|
||||
processDatabaseObjectDefinitions();
|
||||
processTypeDefinitions();
|
||||
}
|
||||
|
||||
private void bindDatabaseObjectDefinitions() {
|
||||
private void processDatabaseObjectDefinitions() {
|
||||
if ( hibernateMapping.getDatabaseObject() == null ) {
|
||||
return;
|
||||
}
|
||||
|
@ -167,7 +173,7 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
if ( databaseObjectElement.getDefinition() != null ) {
|
||||
final String className = databaseObjectElement.getDefinition().getClazz();
|
||||
try {
|
||||
auxiliaryDatabaseObject = (AuxiliaryDatabaseObject) classLoaderService().classForName( className ).newInstance();
|
||||
auxiliaryDatabaseObject = (AuxiliaryDatabaseObject) classLoaderService.getValue().classForName( className ).newInstance();
|
||||
}
|
||||
catch (ClassLoadingException e) {
|
||||
throw e;
|
||||
|
@ -196,7 +202,7 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
}
|
||||
}
|
||||
|
||||
private void bindTypeDefinitions() {
|
||||
private void processTypeDefinitions() {
|
||||
if ( hibernateMapping.getTypedef() == null ) {
|
||||
return;
|
||||
}
|
||||
|
@ -209,12 +215,12 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
}
|
||||
}
|
||||
|
||||
public void bindTypeDependentMetadata() {
|
||||
bindFilterDefinitions();
|
||||
bindIdentifierGenerators();
|
||||
public void processTypeDependentMetadata() {
|
||||
processFilterDefinitions();
|
||||
processIdentifierGenerators();
|
||||
}
|
||||
|
||||
private void bindFilterDefinitions() {
|
||||
private void processFilterDefinitions() {
|
||||
if(hibernateMapping.getFilterDef() == null){
|
||||
return;
|
||||
}
|
||||
|
@ -249,7 +255,7 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
}
|
||||
}
|
||||
|
||||
private void bindIdentifierGenerators() {
|
||||
private void processIdentifierGenerators() {
|
||||
if ( hibernateMapping.getIdentifierGenerator() == null ) {
|
||||
return;
|
||||
}
|
||||
|
@ -262,10 +268,17 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
}
|
||||
|
||||
|
||||
public void bindMappingMetadata(List<String> processedEntityNames) {
|
||||
public void processMappingMetadata(List<String> processedEntityNames) {
|
||||
if ( hibernateMapping.getClazzOrSubclassOrJoinedSubclass() == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
for ( Object entityElementO : hibernateMapping.getClazzOrSubclassOrJoinedSubclass() ) {
|
||||
final EntityElement entityElement = (EntityElement) entityElementO;
|
||||
|
||||
|
||||
}
|
||||
|
||||
for ( Object clazzOrSubclass : hibernateMapping.getClazzOrSubclassOrJoinedSubclass() ) {
|
||||
if ( XMLHibernateMapping.XMLClass.class.isInstance( clazzOrSubclass ) ) {
|
||||
XMLHibernateMapping.XMLClass clazz =
|
||||
|
@ -293,21 +306,21 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
}
|
||||
}
|
||||
|
||||
public void bindMappingDependentMetadata() {
|
||||
bindFetchProfiles();
|
||||
bindImports();
|
||||
bindResultSetMappings();
|
||||
bindNamedQueries();
|
||||
public void processMappingDependentMetadata() {
|
||||
processFetchProfiles();
|
||||
processImports();
|
||||
processResultSetMappings();
|
||||
processNamedQueries();
|
||||
}
|
||||
|
||||
private void bindFetchProfiles(){
|
||||
if(hibernateMapping.getFetchProfile() == null){
|
||||
private void processFetchProfiles(){
|
||||
if ( hibernateMapping.getFetchProfile() == null ) {
|
||||
return;
|
||||
}
|
||||
bindFetchProfiles( hibernateMapping.getFetchProfile(),null );
|
||||
processFetchProfiles( hibernateMapping.getFetchProfile(), null );
|
||||
}
|
||||
|
||||
public void bindFetchProfiles(List<XMLFetchProfileElement> fetchProfiles, String containingEntityName) {
|
||||
public void processFetchProfiles(List<XMLFetchProfileElement> fetchProfiles, String containingEntityName) {
|
||||
for ( XMLFetchProfileElement fetchProfile : fetchProfiles ) {
|
||||
String profileName = fetchProfile.getName();
|
||||
Set<FetchProfile.Fetch> fetches = new HashSet<FetchProfile.Fetch>();
|
||||
|
@ -326,7 +339,7 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
}
|
||||
}
|
||||
|
||||
private void bindImports() {
|
||||
private void processImports() {
|
||||
if ( hibernateMapping.getImport() == null ) {
|
||||
return;
|
||||
}
|
||||
|
@ -338,14 +351,14 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
}
|
||||
}
|
||||
|
||||
private void bindResultSetMappings() {
|
||||
private void processResultSetMappings() {
|
||||
if ( hibernateMapping.getResultset() == null ) {
|
||||
return;
|
||||
}
|
||||
// bindResultSetMappingDefinitions( element, null, mappings );
|
||||
}
|
||||
|
||||
private void bindNamedQueries() {
|
||||
private void processNamedQueries() {
|
||||
if ( hibernateMapping.getQueryOrSqlQuery() == null ) {
|
||||
return;
|
||||
}
|
||||
|
@ -365,14 +378,14 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
}
|
||||
}
|
||||
|
||||
private ClassLoaderService classLoaderService;
|
||||
|
||||
private ClassLoaderService classLoaderService() {
|
||||
if ( classLoaderService == null ) {
|
||||
classLoaderService = metadata.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
}
|
||||
return classLoaderService;
|
||||
}
|
||||
private Value<ClassLoaderService> classLoaderService = new Value<ClassLoaderService>(
|
||||
new Value.DeferredInitializer<ClassLoaderService>() {
|
||||
@Override
|
||||
public ClassLoaderService initialize() {
|
||||
return metadata.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@Override
|
||||
public String extractEntityName(XMLHibernateMapping.XMLClass entityClazz) {
|
||||
|
@ -383,4 +396,9 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
public String getClassName(String unqualifiedName) {
|
||||
return HbmHelper.getClassName( unqualifiedName, mappingDefaults.getPackageName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String determineEntityName(EntityElement entityElement) {
|
||||
return HbmHelper.determineEntityName( entityElement, mappingDefaults.getPackageName() );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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.hbm.xml.mapping;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface Discriminated {
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* 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.hbm.xml.mapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface EntityElement extends MetaAttributeContainer {
|
||||
public String getName();
|
||||
public String getEntityName();
|
||||
|
||||
public Boolean isAbstract();
|
||||
public Boolean isLazy();
|
||||
public String getProxy();
|
||||
public String getBatchSize();
|
||||
public boolean isDynamicInsert();
|
||||
public boolean isDynamicUpdate();
|
||||
public boolean isSelectBeforeUpdate();
|
||||
|
||||
public List<XMLTuplizerElement> getTuplizer();
|
||||
public String getPersister();
|
||||
|
||||
public XMLLoaderElement getLoader();
|
||||
public XMLSqlInsertElement getSqlInsert();
|
||||
public XMLSqlUpdateElement getSqlUpdate();
|
||||
public XMLSqlDeleteElement getSqlDelete();
|
||||
|
||||
public List<XMLSynchronizeElement> getSynchronize();
|
||||
|
||||
public List<XMLFetchProfileElement> getFetchProfile();
|
||||
|
||||
public List<XMLResultsetElement> getResultset();
|
||||
|
||||
public List<Object> getQueryOrSqlQuery();
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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.hbm.xml.mapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface MetaAttributeContainer {
|
||||
public List<XMLMetaElement> getMeta();
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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.hbm.xml.mapping;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SubclassEntityElement extends EntityElement {
|
||||
public String getExtends();
|
||||
}
|
|
@ -565,7 +565,7 @@ public class EntityMetamodel implements Serializable {
|
|||
|
||||
entityMode = hasPojoRepresentation ? EntityMode.POJO : EntityMode.MAP;
|
||||
final EntityTuplizerFactory entityTuplizerFactory = sessionFactory.getSettings().getEntityTuplizerFactory();
|
||||
Class<EntityTuplizer> tuplizerClass = entityBinding.getCustomEntityTuplizerClass();
|
||||
Class<? extends EntityTuplizer> tuplizerClass = entityBinding.getCustomEntityTuplizerClass();
|
||||
|
||||
if ( tuplizerClass == null ) {
|
||||
entityTuplizer = entityTuplizerFactory.constructDefaultTuplizer( entityMode, this, entityBinding );
|
||||
|
|
Loading…
Reference in New Issue