HHH-6371 - Develop metamodel binding creation using a push approach
This commit is contained in:
parent
99f8d26270
commit
182150769a
|
@ -1150,7 +1150,7 @@ public final class HbmBinder {
|
|||
mappings.addColumnBinding( logicalName, column, table );
|
||||
/* TODO: joinKeyColumnName & foreignKeyColumnName should be called either here or at a
|
||||
* slightly higer level in the stack (to get all the information we need)
|
||||
* Right now HbmBinder does not support the
|
||||
* Right now HbmSourceProcessor does not support the
|
||||
*/
|
||||
simpleValue.getTable().addColumn( column );
|
||||
simpleValue.addColumn( column );
|
||||
|
|
|
@ -354,7 +354,7 @@ public class SettingsFactory implements Serializable {
|
|||
}
|
||||
//todo remove this once we move to new metamodel
|
||||
public static RegionFactory createRegionFactory(Properties properties, boolean cachingEnabled) {
|
||||
// todo : REMOVE! THIS IS TOTALLY A TEMPORARY HACK FOR org.hibernate.cfg.AnnotationBinder which will be going away
|
||||
// todo : REMOVE! THIS IS TOTALLY A TEMPORARY HACK FOR org.hibernate.cfg.AnnotationSourceProcessor which will be going away
|
||||
String regionFactoryClassName = ConfigurationHelper.getString(
|
||||
Environment.CACHE_REGION_FACTORY, properties, null
|
||||
);
|
||||
|
|
|
@ -83,7 +83,7 @@ public class ToOneFkSecondPass extends FkSecondPass {
|
|||
}
|
||||
else {
|
||||
//try the embedded property
|
||||
//embedded property starts their path with 'id.' See PropertyPreloadedData( ) use when idClass != null in AnnotationBinder
|
||||
//embedded property starts their path with 'id.' See PropertyPreloadedData( ) use when idClass != null in AnnotationSourceProcessor
|
||||
if ( path.startsWith( "id." ) ) {
|
||||
KeyValue valueIdentifier = persistentClass.getIdentifier();
|
||||
String localPath = path.substring( 3 );
|
||||
|
@ -115,7 +115,7 @@ public class ToOneFkSecondPass extends FkSecondPass {
|
|||
BinderHelper.createSyntheticPropertyReference( columns, ref, null, manyToOne, false, mappings );
|
||||
TableBinder.bindFk( ref, null, columns, manyToOne, unique, mappings );
|
||||
/*
|
||||
* HbmBinder does this only when property-ref != null, but IMO, it makes sense event if it is null
|
||||
* HbmSourceProcessor does this only when property-ref != null, but IMO, it makes sense event if it is null
|
||||
*/
|
||||
if ( !manyToOne.isIgnoreNotFound() ) manyToOne.createPropertyRefConstraints( persistentClasses );
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ public class PropertyBinder {
|
|||
|
||||
private Property makePropertyAndValue() {
|
||||
validateBind();
|
||||
LOG.debugf("Binder property %s with lazy=%s", name, lazy);
|
||||
LOG.debugf("SourceProcessor property %s with lazy=%s", name, lazy);
|
||||
String containerClassName = holder == null ?
|
||||
null :
|
||||
holder.getClassName();
|
||||
|
|
|
@ -90,10 +90,6 @@ public interface CoreMessageLogger extends BasicLogger {
|
|||
@Message(value = "On release of batch it still contained JDBC statements", id = 10)
|
||||
void batchContainedStatementsOnRelease();
|
||||
|
||||
@LogMessage(level = DEBUG)
|
||||
@Message(value = "Binding entity from annotated class: %s", id = 15)
|
||||
void bindingEntityFromAnnotatedClass(String className);
|
||||
|
||||
@LogMessage(level = INFO)
|
||||
@Message(value = "Bytecode provider name : %s", id = 21)
|
||||
void bytecodeProvider(String provider);
|
||||
|
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* 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.binder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.metamodel.binder.view.EntityView;
|
||||
import org.hibernate.metamodel.binder.view.TableView;
|
||||
import org.hibernate.metamodel.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
import org.hibernate.metamodel.domain.Entity;
|
||||
import org.hibernate.metamodel.domain.JavaType;
|
||||
import org.hibernate.metamodel.relational.Identifier;
|
||||
import org.hibernate.metamodel.relational.Schema;
|
||||
import org.hibernate.metamodel.relational.Table;
|
||||
import org.hibernate.metamodel.source.MappingException;
|
||||
import org.hibernate.metamodel.source.spi.BindingContext;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class EntityBinder {
|
||||
private final BindingContext bindingContext;
|
||||
|
||||
public EntityBinder(BindingContext bindingContext) {
|
||||
this.bindingContext = bindingContext;
|
||||
}
|
||||
|
||||
public EntityBinding createEntityBinding(EntityView entityView) {
|
||||
final EntityBinding entityBinding = new EntityBinding();
|
||||
|
||||
// todo : Entity will need both entityName and className to be effective
|
||||
final Entity entity = new Entity( entityView.getEntityName(), entityView.getSuperType(), bindingContext.makeJavaType( entityView.getClassName() ) );
|
||||
entityBinding.setEntity( entity );
|
||||
|
||||
final TableView baseTableView = entityView.getBaseTable();
|
||||
|
||||
final String schemaName = baseTableView.getExplicitSchemaName() == null
|
||||
? bindingContext.getMappingDefaults().getSchemaName()
|
||||
: baseTableView.getExplicitSchemaName();
|
||||
final String catalogName = baseTableView.getExplicitCatalogName() == null
|
||||
? bindingContext.getMappingDefaults().getCatalogName()
|
||||
: baseTableView.getExplicitCatalogName();
|
||||
final Schema.Name fullSchemaName = new Schema.Name( schemaName, catalogName );
|
||||
final Schema schema = bindingContext.getMetadataImplementor().getDatabase().getSchema( fullSchemaName );
|
||||
final Identifier tableName = Identifier.toIdentifier( baseTableView.getTableName() );
|
||||
final Table baseTable = schema.locateOrCreateTable( tableName );
|
||||
entityBinding.setBaseTable( baseTable );
|
||||
|
||||
// inheritance
|
||||
if ( entityView.getEntityInheritanceType() != InheritanceType.NO_INHERITANCE ) {
|
||||
// if there is any inheritance strategy, there has to be a super type.
|
||||
if ( entityView.getSuperType() == null ) {
|
||||
throw new MappingException( "Encountered inheritance strategy, but no super type", entityView.getOrigin() );
|
||||
}
|
||||
}
|
||||
entityBinding.setRoot( entityView.isRoot() );
|
||||
entityBinding.setInheritanceType( entityView.getEntityInheritanceType() );
|
||||
|
||||
entityBinding.setJpaEntityName( entityView.getJpaEntityName() );
|
||||
entityBinding.setEntityMode( entityView.getEntityMode() );
|
||||
|
||||
if ( entityView.getEntityMode() == EntityMode.POJO ) {
|
||||
if ( entityView.getProxyInterfaceName() != null ) {
|
||||
entityBinding.setProxyInterfaceType( bindingContext.makeJavaType( entityView.getProxyInterfaceName() ) );
|
||||
entityBinding.setLazy( true );
|
||||
}
|
||||
else if ( entityView.isLazy() ) {
|
||||
entityBinding.setProxyInterfaceType( entity.getJavaType() );
|
||||
entityBinding.setLazy( true );
|
||||
}
|
||||
}
|
||||
else {
|
||||
entityBinding.setProxyInterfaceType( new JavaType( Map.class ) );
|
||||
entityBinding.setLazy( entityView.isLazy() );
|
||||
}
|
||||
|
||||
entityBinding.setCustomEntityTuplizerClass( entityView.getCustomEntityTuplizerClass() );
|
||||
entityBinding.setCustomEntityPersisterClass( entityView.getCustomEntityPersisterClass() );
|
||||
|
||||
entityBinding.setCaching( entityView.getCaching() );
|
||||
entityBinding.setMetaAttributeContext( entityView.getMetaAttributeContext() );
|
||||
|
||||
entityBinding.setMutable( entityView.isMutable() );
|
||||
entityBinding.setExplicitPolymorphism( entityView.isExplicitPolymorphism() );
|
||||
entityBinding.setWhereFilter( entityView.getWhereFilter() );
|
||||
entityBinding.setRowId( entityView.getRowId() );
|
||||
entityBinding.setDynamicUpdate( entityView.isDynamicUpdate() );
|
||||
entityBinding.setDynamicInsert( entityView.isDynamicInsert() );
|
||||
entityBinding.setBatchSize( entityView.getBatchSize() );
|
||||
entityBinding.setSelectBeforeUpdate( entityView.isSelectBeforeUpdate() );
|
||||
entityBinding.setOptimisticLockMode( entityView.getOptimisticLockMode() );
|
||||
entityBinding.setAbstract( entityView.isAbstract() );
|
||||
|
||||
entityBinding.setCustomLoaderName( entityView.getCustomLoaderName() );
|
||||
entityBinding.setCustomInsert( entityView.getCustomInsert() );
|
||||
entityBinding.setCustomUpdate( entityView.getCustomUpdate() );
|
||||
entityBinding.setCustomDelete( entityView.getCustomDelete() );
|
||||
|
||||
if ( entityView.getSynchronizedTableNames() != null ) {
|
||||
entityBinding.addSynchronizedTableNames( entityView.getSynchronizedTableNames() );
|
||||
}
|
||||
|
||||
return entityBinding;
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.binding.state;
|
||||
package org.hibernate.metamodel.binder.view;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -30,17 +30,16 @@ import org.hibernate.metamodel.binding.Caching;
|
|||
import org.hibernate.metamodel.binding.CustomSQL;
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
import org.hibernate.metamodel.domain.Hierarchical;
|
||||
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.tuple.entity.EntityTuplizer;
|
||||
|
||||
/**
|
||||
* Represents unified set of information about metadata specific to binding an entity.
|
||||
* Represents the normalized set of mapping information about a specific entity.
|
||||
*
|
||||
* @author Gail Badner
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface EntityBindingState {
|
||||
public interface EntityView extends NormalizedViewObject {
|
||||
/**
|
||||
* Obtain the Hibernate entity name.
|
||||
*
|
||||
|
@ -76,20 +75,45 @@ public interface EntityBindingState {
|
|||
*/
|
||||
public String getProxyInterfaceName();
|
||||
|
||||
public Class<EntityPersister> getCustomEntityPersisterClass();
|
||||
/**
|
||||
* Is this entity the root of a mapped inheritance hierarchy?
|
||||
*
|
||||
* @return {@code true} if this entity is an inheritance root; {@code false} otherwise.
|
||||
*/
|
||||
public boolean isRoot();
|
||||
|
||||
public Class<EntityTuplizer> getCustomEntityTuplizerClass();
|
||||
/**
|
||||
* Obtains the type of inheritance defined for this entity hierarchy
|
||||
*
|
||||
* @return The inheritance strategy for this entity.
|
||||
*/
|
||||
public InheritanceType getEntityInheritanceType();
|
||||
|
||||
/**
|
||||
* Obtain the super type for this entity.
|
||||
*
|
||||
* @return This entity's super type.
|
||||
*/
|
||||
public Hierarchical getSuperType();
|
||||
|
||||
boolean isRoot();
|
||||
/**
|
||||
* Obtain the custom {@link EntityPersister} class defined in this mapping. {@code null} indicates the default
|
||||
* should be used.
|
||||
*
|
||||
* @return The custom {@link EntityPersister} class to use; or {@code null}
|
||||
*/
|
||||
public Class<? extends EntityPersister> getCustomEntityPersisterClass();
|
||||
|
||||
InheritanceType getEntityInheritanceType();
|
||||
/**
|
||||
* Obtain the custom {@link EntityTuplizer} class defined in this mapping. {@code null} indicates the default
|
||||
* should be used.
|
||||
*
|
||||
* @return The custom {@link EntityTuplizer} class to use; or {@code null}
|
||||
*/
|
||||
public Class<? extends EntityTuplizer> getCustomEntityTuplizerClass();
|
||||
|
||||
Caching getCaching();
|
||||
|
||||
MetaAttributeContext getMetaAttributeContext();
|
||||
|
||||
boolean isLazy();
|
||||
|
||||
boolean isMutable();
|
||||
|
@ -110,9 +134,10 @@ public interface EntityBindingState {
|
|||
|
||||
int getOptimisticLockMode();
|
||||
|
||||
|
||||
Boolean isAbstract();
|
||||
|
||||
String getCustomLoaderName();
|
||||
|
||||
CustomSQL getCustomInsert();
|
||||
|
||||
CustomSQL getCustomUpdate();
|
||||
|
@ -120,4 +145,7 @@ public interface EntityBindingState {
|
|||
CustomSQL getCustomDelete();
|
||||
|
||||
Set<String> getSynchronizedTableNames();
|
||||
|
||||
|
||||
public TableView getBaseTable();
|
||||
}
|
|
@ -21,19 +21,16 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.spi;
|
||||
package org.hibernate.metamodel.binder.view;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.metamodel.MetadataSources;
|
||||
import org.hibernate.metamodel.source.Origin;
|
||||
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface Binder {
|
||||
public void prepare(MetadataSources sources);
|
||||
public void bindIndependentMetadata(MetadataSources sources);
|
||||
public void bindTypeDependentMetadata(MetadataSources sources);
|
||||
public void bindMappingMetadata(MetadataSources sources, List<String> processedEntityNames);
|
||||
public void bindMappingDependentMetadata(MetadataSources sources);
|
||||
public interface NormalizedViewObject {
|
||||
public NormalizedViewObject getContainingViewObject();
|
||||
public Origin getOrigin();
|
||||
public MetaAttributeContext getMetaAttributeContext();
|
||||
}
|
|
@ -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.binder.view;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface TableView extends NormalizedViewObject {
|
||||
public String getExplicitSchemaName();
|
||||
public String getExplicitCatalogName();
|
||||
public String getTableName();
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.hbm.state.binding;
|
||||
package org.hibernate.metamodel.binder.view.hbm;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -30,11 +30,14 @@ import org.hibernate.EntityMode;
|
|||
import org.hibernate.MappingException;
|
||||
import org.hibernate.cache.spi.access.AccessType;
|
||||
import org.hibernate.engine.internal.Versioning;
|
||||
import org.hibernate.metamodel.binder.view.EntityView;
|
||||
import org.hibernate.metamodel.binder.view.NormalizedViewObject;
|
||||
import org.hibernate.metamodel.binder.view.TableView;
|
||||
import org.hibernate.metamodel.binding.Caching;
|
||||
import org.hibernate.metamodel.binding.CustomSQL;
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
import org.hibernate.metamodel.binding.state.EntityBindingState;
|
||||
import org.hibernate.metamodel.domain.Hierarchical;
|
||||
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;
|
||||
|
@ -51,8 +54,11 @@ import org.hibernate.tuple.entity.EntityTuplizer;
|
|||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class HbmEntityBindingState implements EntityBindingState {
|
||||
public class EntityViewImpl implements EntityView {
|
||||
private final HbmBindingContext bindingContext;
|
||||
|
||||
private final String entityName;
|
||||
private final EntityMode entityMode;
|
||||
|
||||
|
@ -85,19 +91,24 @@ public class HbmEntityBindingState implements EntityBindingState {
|
|||
|
||||
private final Boolean isAbstract;
|
||||
|
||||
private final String customLoaderName;
|
||||
private final CustomSQL customInsert;
|
||||
private final CustomSQL customUpdate;
|
||||
private final CustomSQL customDelete;
|
||||
|
||||
private final Set<String> synchronizedTableNames;
|
||||
|
||||
public HbmEntityBindingState(
|
||||
private final TableView baseTableView;
|
||||
|
||||
public EntityViewImpl(
|
||||
Hierarchical superType,
|
||||
XMLHibernateMapping.XMLClass entityClazz,
|
||||
boolean isRoot,
|
||||
InheritanceType inheritanceType,
|
||||
HbmBindingContext bindingContext) {
|
||||
|
||||
this.bindingContext = bindingContext;
|
||||
|
||||
this.superType = superType;
|
||||
this.entityName = bindingContext.extractEntityName( entityClazz );
|
||||
|
||||
|
@ -114,86 +125,94 @@ public class HbmEntityBindingState implements EntityBindingState {
|
|||
}
|
||||
|
||||
final String customTuplizerClassName = extractCustomTuplizerClassName( entityClazz, entityMode );
|
||||
tuplizerClass = customTuplizerClassName != null
|
||||
this.tuplizerClass = customTuplizerClassName != null
|
||||
? bindingContext.<EntityTuplizer>locateClassByName( customTuplizerClassName )
|
||||
: null;
|
||||
this.entityPersisterClass = entityClazz.getPersister() == null
|
||||
? null
|
||||
: bindingContext.<EntityPersister>locateClassByName( entityClazz.getPersister() );
|
||||
|
||||
this.isRoot = isRoot;
|
||||
this.entityInheritanceType = inheritanceType;
|
||||
|
||||
this.caching = createCaching( entityClazz, bindingContext.extractEntityName( entityClazz ) );
|
||||
|
||||
metaAttributeContext = HbmHelper.extractMetaAttributeContext(
|
||||
this.metaAttributeContext = HbmHelper.extractMetaAttributeContext(
|
||||
entityClazz.getMeta(), true, bindingContext.getMetaAttributeContext()
|
||||
);
|
||||
|
||||
// go ahead and set the lazy here, since pojo.proxy can override it.
|
||||
lazy = MappingHelper.getBooleanValue(
|
||||
this.lazy = MappingHelper.getBooleanValue(
|
||||
entityClazz.isLazy(), bindingContext.getMappingDefaults().areAssociationsLazy()
|
||||
);
|
||||
mutable = entityClazz.isMutable();
|
||||
this.mutable = entityClazz.isMutable();
|
||||
|
||||
explicitPolymorphism = "explicit".equals( entityClazz.getPolymorphism() );
|
||||
whereFilter = entityClazz.getWhere();
|
||||
rowId = entityClazz.getRowid();
|
||||
dynamicUpdate = entityClazz.isDynamicUpdate();
|
||||
dynamicInsert = entityClazz.isDynamicInsert();
|
||||
batchSize = MappingHelper.getIntValue( entityClazz.getBatchSize(), 0 );
|
||||
selectBeforeUpdate = entityClazz.isSelectBeforeUpdate();
|
||||
optimisticLockMode = getOptimisticLockMode();
|
||||
this.explicitPolymorphism = "explicit".equals( entityClazz.getPolymorphism() );
|
||||
this.whereFilter = entityClazz.getWhere();
|
||||
this.rowId = entityClazz.getRowid();
|
||||
this.dynamicUpdate = entityClazz.isDynamicUpdate();
|
||||
this.dynamicInsert = entityClazz.isDynamicInsert();
|
||||
this.batchSize = MappingHelper.getIntValue( entityClazz.getBatchSize(), 0 );
|
||||
this.selectBeforeUpdate = entityClazz.isSelectBeforeUpdate();
|
||||
this.optimisticLockMode = getOptimisticLockMode();
|
||||
|
||||
// PERSISTER
|
||||
entityPersisterClass = entityClazz.getPersister() == null
|
||||
? null
|
||||
: bindingContext.<EntityPersister>locateClassByName( entityClazz.getPersister() );
|
||||
this.customLoaderName = entityClazz.getLoader().getQueryRef();
|
||||
|
||||
// CUSTOM SQL
|
||||
XMLSqlInsertElement sqlInsert = entityClazz.getSqlInsert();
|
||||
if ( sqlInsert != null ) {
|
||||
customInsert = HbmHelper.getCustomSql(
|
||||
this.customInsert = HbmHelper.getCustomSql(
|
||||
sqlInsert.getValue(),
|
||||
sqlInsert.isCallable(),
|
||||
sqlInsert.getCheck().value()
|
||||
);
|
||||
}
|
||||
else {
|
||||
customInsert = null;
|
||||
this.customInsert = null;
|
||||
}
|
||||
|
||||
XMLSqlDeleteElement sqlDelete = entityClazz.getSqlDelete();
|
||||
if ( sqlDelete != null ) {
|
||||
customDelete = HbmHelper.getCustomSql(
|
||||
this.customDelete = HbmHelper.getCustomSql(
|
||||
sqlDelete.getValue(),
|
||||
sqlDelete.isCallable(),
|
||||
sqlDelete.getCheck().value()
|
||||
);
|
||||
}
|
||||
else {
|
||||
customDelete = null;
|
||||
this.customDelete = null;
|
||||
}
|
||||
|
||||
XMLSqlUpdateElement sqlUpdate = entityClazz.getSqlUpdate();
|
||||
if ( sqlUpdate != null ) {
|
||||
customUpdate = HbmHelper.getCustomSql(
|
||||
this.customUpdate = HbmHelper.getCustomSql(
|
||||
sqlUpdate.getValue(),
|
||||
sqlUpdate.isCallable(),
|
||||
sqlUpdate.getCheck().value()
|
||||
);
|
||||
}
|
||||
else {
|
||||
customUpdate = null;
|
||||
this.customUpdate = null;
|
||||
}
|
||||
|
||||
if ( entityClazz.getSynchronize() != null ) {
|
||||
synchronizedTableNames = new HashSet<String>( entityClazz.getSynchronize().size() );
|
||||
this.synchronizedTableNames = new HashSet<String>( entityClazz.getSynchronize().size() );
|
||||
for ( XMLSynchronizeElement synchronize : entityClazz.getSynchronize() ) {
|
||||
synchronizedTableNames.add( synchronize.getTable() );
|
||||
this.synchronizedTableNames.add( synchronize.getTable() );
|
||||
}
|
||||
}
|
||||
else {
|
||||
synchronizedTableNames = null;
|
||||
this.synchronizedTableNames = null;
|
||||
}
|
||||
isAbstract = entityClazz.isAbstract();
|
||||
|
||||
this.isAbstract = entityClazz.isAbstract();
|
||||
|
||||
this.baseTableView = new TableViewImpl(
|
||||
entityClazz.getSchema(),
|
||||
entityClazz.getCatalog(),
|
||||
entityClazz.getTable(),
|
||||
this,
|
||||
bindingContext
|
||||
);
|
||||
}
|
||||
|
||||
private String extractCustomTuplizerClassName(XMLHibernateMapping.XMLClass entityClazz, EntityMode entityMode) {
|
||||
|
@ -374,4 +393,24 @@ public class HbmEntityBindingState implements EntityBindingState {
|
|||
public Set<String> getSynchronizedTableNames() {
|
||||
return synchronizedTableNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomLoaderName() {
|
||||
return customLoaderName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableView getBaseTable() {
|
||||
return baseTableView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NormalizedViewObject getContainingViewObject() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Origin getOrigin() {
|
||||
return bindingContext.getOrigin();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* 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.binder.view.hbm;
|
||||
|
||||
import org.hibernate.metamodel.binder.view.TableView;
|
||||
import org.hibernate.metamodel.source.hbm.HbmBindingContext;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class TableViewImpl implements TableView {
|
||||
private final String explicitSchemaName;
|
||||
private final String explicitCatalogName;
|
||||
private final String tableName;
|
||||
|
||||
public TableViewImpl(
|
||||
String explicitSchemaName,
|
||||
String explicitCatalogName,
|
||||
String tableName,
|
||||
EntityViewImpl entityView,
|
||||
HbmBindingContext bindingContext) {
|
||||
this.explicitSchemaName = explicitSchemaName;
|
||||
this.explicitCatalogName = explicitCatalogName;
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExplicitSchemaName() {
|
||||
return explicitSchemaName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExplicitCatalogName() {
|
||||
return explicitCatalogName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
}
|
|
@ -32,7 +32,7 @@ import org.hibernate.AssertionFailure;
|
|||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.engine.spi.FilterDefinition;
|
||||
import org.hibernate.metamodel.binding.state.EntityBindingState;
|
||||
import org.hibernate.metamodel.binder.view.EntityView;
|
||||
import org.hibernate.metamodel.domain.Attribute;
|
||||
import org.hibernate.metamodel.domain.Entity;
|
||||
import org.hibernate.metamodel.domain.JavaType;
|
||||
|
@ -59,8 +59,8 @@ public class EntityBinding {
|
|||
|
||||
private String jpaEntityName;
|
||||
|
||||
private Class<EntityPersister> entityPersisterClass;
|
||||
private Class<EntityTuplizer> entityTuplizerClass;
|
||||
private Class<? extends EntityPersister> customEntityPersisterClass;
|
||||
private Class<? extends EntityTuplizer> customEntityTuplizerClass;
|
||||
|
||||
private boolean isRoot;
|
||||
private InheritanceType entityInheritanceType;
|
||||
|
@ -93,13 +93,14 @@ public class EntityBinding {
|
|||
|
||||
private Boolean isAbstract;
|
||||
|
||||
private String customLoaderName;
|
||||
private CustomSQL customInsert;
|
||||
private CustomSQL customUpdate;
|
||||
private CustomSQL customDelete;
|
||||
|
||||
private Set<String> synchronizedTableNames = new HashSet<String>();
|
||||
|
||||
public EntityBinding initialize(BindingContext bindingContext, EntityBindingState state) {
|
||||
public EntityBinding initialize(BindingContext bindingContext, EntityView state) {
|
||||
// todo : Entity will need both entityName and className to be effective
|
||||
this.entity = new Entity(
|
||||
state.getEntityName(),
|
||||
|
@ -114,8 +115,8 @@ public class EntityBinding {
|
|||
this.jpaEntityName = state.getJpaEntityName();
|
||||
|
||||
// todo : handle the entity-persister-resolver stuff
|
||||
this.entityPersisterClass = state.getCustomEntityPersisterClass();
|
||||
this.entityTuplizerClass = state.getCustomEntityTuplizerClass();
|
||||
this.customEntityPersisterClass = state.getCustomEntityPersisterClass();
|
||||
this.customEntityTuplizerClass = state.getCustomEntityTuplizerClass();
|
||||
|
||||
this.caching = state.getCaching();
|
||||
this.metaAttributeContext = state.getMetaAttributeContext();
|
||||
|
@ -156,14 +157,6 @@ public class EntityBinding {
|
|||
return this;
|
||||
}
|
||||
|
||||
public boolean isRoot() {
|
||||
return isRoot;
|
||||
}
|
||||
|
||||
public void setRoot(boolean isRoot) {
|
||||
this.isRoot = isRoot;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
@ -180,6 +173,14 @@ public class EntityBinding {
|
|||
this.baseTable = baseTable;
|
||||
}
|
||||
|
||||
public boolean isRoot() {
|
||||
return isRoot;
|
||||
}
|
||||
|
||||
public void setRoot(boolean isRoot) {
|
||||
this.isRoot = isRoot;
|
||||
}
|
||||
|
||||
public EntityIdentifier getEntityIdentifier() {
|
||||
return entityIdentifier;
|
||||
}
|
||||
|
@ -318,14 +319,26 @@ public class EntityBinding {
|
|||
return caching;
|
||||
}
|
||||
|
||||
public void setCaching(Caching caching) {
|
||||
this.caching = caching;
|
||||
}
|
||||
|
||||
public MetaAttributeContext getMetaAttributeContext() {
|
||||
return metaAttributeContext;
|
||||
}
|
||||
|
||||
public void setMetaAttributeContext(MetaAttributeContext metaAttributeContext) {
|
||||
this.metaAttributeContext = metaAttributeContext;
|
||||
}
|
||||
|
||||
public boolean isMutable() {
|
||||
return mutable;
|
||||
}
|
||||
|
||||
public void setMutable(boolean mutable) {
|
||||
this.mutable = mutable;
|
||||
}
|
||||
|
||||
public boolean isLazy() {
|
||||
return lazy;
|
||||
}
|
||||
|
@ -338,18 +351,34 @@ public class EntityBinding {
|
|||
return proxyInterfaceType;
|
||||
}
|
||||
|
||||
public void setProxyInterfaceType(JavaType proxyInterfaceType) {
|
||||
this.proxyInterfaceType = proxyInterfaceType;
|
||||
}
|
||||
|
||||
public String getWhereFilter() {
|
||||
return whereFilter;
|
||||
}
|
||||
|
||||
public void setWhereFilter(String whereFilter) {
|
||||
this.whereFilter = whereFilter;
|
||||
}
|
||||
|
||||
public boolean isExplicitPolymorphism() {
|
||||
return explicitPolymorphism;
|
||||
}
|
||||
|
||||
public void setExplicitPolymorphism(boolean explicitPolymorphism) {
|
||||
this.explicitPolymorphism = explicitPolymorphism;
|
||||
}
|
||||
|
||||
public String getRowId() {
|
||||
return rowId;
|
||||
}
|
||||
|
||||
public void setRowId(String rowId) {
|
||||
this.rowId = rowId;
|
||||
}
|
||||
|
||||
public String getDiscriminatorValue() {
|
||||
return entityDiscriminator == null ? null : entityDiscriminator.getDiscriminatorValue();
|
||||
}
|
||||
|
@ -358,18 +387,34 @@ public class EntityBinding {
|
|||
return dynamicUpdate;
|
||||
}
|
||||
|
||||
public void setDynamicUpdate(boolean dynamicUpdate) {
|
||||
this.dynamicUpdate = dynamicUpdate;
|
||||
}
|
||||
|
||||
public boolean isDynamicInsert() {
|
||||
return dynamicInsert;
|
||||
}
|
||||
|
||||
public void setDynamicInsert(boolean dynamicInsert) {
|
||||
this.dynamicInsert = dynamicInsert;
|
||||
}
|
||||
|
||||
public int getBatchSize() {
|
||||
return batchSize;
|
||||
}
|
||||
|
||||
public void setBatchSize(int batchSize) {
|
||||
this.batchSize = batchSize;
|
||||
}
|
||||
|
||||
public boolean isSelectBeforeUpdate() {
|
||||
return selectBeforeUpdate;
|
||||
}
|
||||
|
||||
public void setSelectBeforeUpdate(boolean selectBeforeUpdate) {
|
||||
this.selectBeforeUpdate = selectBeforeUpdate;
|
||||
}
|
||||
|
||||
public boolean hasSubselectLoadableCollections() {
|
||||
return hasSubselectLoadableCollections;
|
||||
}
|
||||
|
@ -383,47 +428,91 @@ public class EntityBinding {
|
|||
return optimisticLockMode;
|
||||
}
|
||||
|
||||
public Class<EntityPersister> getEntityPersisterClass() {
|
||||
return entityPersisterClass;
|
||||
public void setOptimisticLockMode(int optimisticLockMode) {
|
||||
this.optimisticLockMode = optimisticLockMode;
|
||||
}
|
||||
|
||||
public Class<EntityTuplizer> getEntityTuplizerClass() {
|
||||
return entityTuplizerClass;
|
||||
public Class<? extends EntityPersister> getCustomEntityPersisterClass() {
|
||||
return customEntityPersisterClass;
|
||||
}
|
||||
|
||||
public void setCustomEntityPersisterClass(Class<? extends EntityPersister> customEntityPersisterClass) {
|
||||
this.customEntityPersisterClass = customEntityPersisterClass;
|
||||
}
|
||||
|
||||
public Class<? extends EntityTuplizer> getCustomEntityTuplizerClass() {
|
||||
return customEntityTuplizerClass;
|
||||
}
|
||||
|
||||
public void setCustomEntityTuplizerClass(Class<? extends EntityTuplizer> customEntityTuplizerClass) {
|
||||
this.customEntityTuplizerClass = customEntityTuplizerClass;
|
||||
}
|
||||
|
||||
public Boolean isAbstract() {
|
||||
return isAbstract;
|
||||
}
|
||||
|
||||
protected void addSynchronizedTable(String tableName) {
|
||||
synchronizedTableNames.add( tableName );
|
||||
public void setAbstract(Boolean isAbstract) {
|
||||
this.isAbstract = isAbstract;
|
||||
}
|
||||
|
||||
public Set<String> getSynchronizedTableNames() {
|
||||
return synchronizedTableNames;
|
||||
}
|
||||
|
||||
// Custom SQL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
private String loaderName;
|
||||
|
||||
public String getLoaderName() {
|
||||
return loaderName;
|
||||
public void addSynchronizedTable(String tableName) {
|
||||
synchronizedTableNames.add( tableName );
|
||||
}
|
||||
|
||||
public void setLoaderName(String loaderName) {
|
||||
this.loaderName = loaderName;
|
||||
public void addSynchronizedTableNames(java.util.Collection<String> synchronizedTableNames) {
|
||||
this.synchronizedTableNames.addAll( synchronizedTableNames );
|
||||
}
|
||||
|
||||
public EntityMode getEntityMode() {
|
||||
return entityMode;
|
||||
}
|
||||
|
||||
public void setEntityMode(EntityMode entityMode) {
|
||||
this.entityMode = entityMode;
|
||||
}
|
||||
|
||||
public String getJpaEntityName() {
|
||||
return jpaEntityName;
|
||||
}
|
||||
|
||||
public void setJpaEntityName(String jpaEntityName) {
|
||||
this.jpaEntityName = jpaEntityName;
|
||||
}
|
||||
|
||||
public String getCustomLoaderName() {
|
||||
return customLoaderName;
|
||||
}
|
||||
|
||||
public void setCustomLoaderName(String customLoaderName) {
|
||||
this.customLoaderName = customLoaderName;
|
||||
}
|
||||
|
||||
public CustomSQL getCustomInsert() {
|
||||
return customInsert;
|
||||
}
|
||||
|
||||
public void setCustomInsert(CustomSQL customInsert) {
|
||||
this.customInsert = customInsert;
|
||||
}
|
||||
|
||||
public CustomSQL getCustomUpdate() {
|
||||
return customUpdate;
|
||||
}
|
||||
|
||||
public void setCustomUpdate(CustomSQL customUpdate) {
|
||||
this.customUpdate = customUpdate;
|
||||
}
|
||||
|
||||
public CustomSQL getCustomDelete() {
|
||||
return customDelete;
|
||||
}
|
||||
|
||||
public void setCustomDelete(CustomSQL customDelete) {
|
||||
this.customDelete = customDelete;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class Schema {
|
|||
return name;
|
||||
}
|
||||
|
||||
public Table getTable(Identifier name) {
|
||||
public Table locateTable(Identifier name) {
|
||||
return tables.get( name );
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,14 @@ public class Schema {
|
|||
return table;
|
||||
}
|
||||
|
||||
public Table locateOrCreateTable(Identifier name) {
|
||||
final Table existing = locateTable( name );
|
||||
if ( existing == null ) {
|
||||
return createTable( name );
|
||||
}
|
||||
return existing;
|
||||
}
|
||||
|
||||
public InLineView getInLineView(String logicalName) {
|
||||
return inLineViews.get( logicalName );
|
||||
}
|
||||
|
|
|
@ -36,5 +36,6 @@ public enum SourceType {
|
|||
URL,
|
||||
STRING,
|
||||
DOM,
|
||||
JAR
|
||||
JAR,
|
||||
OTHER
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.jboss.jandex.Indexer;
|
|||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.Value;
|
||||
import org.hibernate.metamodel.MetadataSources;
|
||||
import org.hibernate.metamodel.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.domain.Hierarchical;
|
||||
|
@ -56,8 +56,8 @@ import org.hibernate.metamodel.source.annotations.xml.OrmXmlParser;
|
|||
import org.hibernate.metamodel.source.annotations.xml.PseudoJpaDotNames;
|
||||
import org.hibernate.metamodel.source.internal.JaxbRoot;
|
||||
import org.hibernate.metamodel.source.internal.MetadataImpl;
|
||||
import org.hibernate.metamodel.source.spi.Binder;
|
||||
import org.hibernate.metamodel.source.spi.MetadataImplementor;
|
||||
import org.hibernate.metamodel.source.spi.SourceProcessor;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
|
||||
/**
|
||||
|
@ -68,19 +68,24 @@ import org.hibernate.service.classloading.spi.ClassLoaderService;
|
|||
* @author Hardy Ferentschik
|
||||
* @see org.hibernate.metamodel.source.annotations.xml.OrmXmlParser
|
||||
*/
|
||||
public class AnnotationBinder implements Binder {
|
||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
|
||||
CoreMessageLogger.class,
|
||||
AnnotationBinder.class.getName()
|
||||
);
|
||||
public class AnnotationSourceProcessor implements SourceProcessor {
|
||||
private static final Logger LOG = Logger.getLogger( AnnotationSourceProcessor.class );
|
||||
|
||||
private final MetadataImpl metadata;
|
||||
private final MetadataImplementor metadata;
|
||||
private final Value<ClassLoaderService> classLoaderService;
|
||||
|
||||
private Index index;
|
||||
private ClassLoaderService classLoaderService;
|
||||
|
||||
public AnnotationBinder(MetadataImpl metadata) {
|
||||
public AnnotationSourceProcessor(MetadataImpl metadata) {
|
||||
this.metadata = metadata;
|
||||
this.classLoaderService = new Value<ClassLoaderService>(
|
||||
new Value.DeferredInitializer<ClassLoaderService>() {
|
||||
@Override
|
||||
public ClassLoaderService initialize() {
|
||||
return AnnotationSourceProcessor.this.metadata.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -112,6 +117,7 @@ public class AnnotationBinder implements Binder {
|
|||
}
|
||||
|
||||
if( index.getAnnotations( PseudoJpaDotNames.DEFAULT_DELIMITED_IDENTIFIERS ) != null ) {
|
||||
// todo : this needs to move to AnnotationBindingContext
|
||||
metadata.setGloballyQuotedIdentifiers( true );
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +129,7 @@ public class AnnotationBinder implements Binder {
|
|||
* @param className the fully qualified class name to be indexed
|
||||
*/
|
||||
private void indexClass(Indexer indexer, String className) {
|
||||
InputStream stream = classLoaderService().locateResourceStream( className );
|
||||
InputStream stream = classLoaderService.getValue().locateResourceStream( className );
|
||||
try {
|
||||
indexer.index( stream );
|
||||
}
|
||||
|
@ -132,26 +138,20 @@ public class AnnotationBinder implements Binder {
|
|||
}
|
||||
}
|
||||
|
||||
private ClassLoaderService classLoaderService() {
|
||||
if ( classLoaderService == null ) {
|
||||
classLoaderService = metadata.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
}
|
||||
return classLoaderService;
|
||||
@Override
|
||||
public void processIndependentMetadata(MetadataSources sources) {
|
||||
TypeDefBinder.bind( metadata, index );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindIndependentMetadata(MetadataSources sources) {
|
||||
TypeDefBinder.bind( metadata, index );
|
||||
public void processTypeDependentMetadata(MetadataSources sources) {
|
||||
IdGeneratorBinder.bind( metadata, index );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindTypeDependentMetadata(MetadataSources sources) {
|
||||
IdGeneratorBinder.bind( metadata, index );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindMappingMetadata(MetadataSources sources, List<String> processedEntityNames) {
|
||||
public void processMappingMetadata(MetadataSources sources, List<String> processedEntityNames) {
|
||||
AnnotationBindingContext context = new AnnotationBindingContext( index, metadata.getServiceRegistry() );
|
||||
|
||||
// need to order our annotated entities into an order we can process
|
||||
Set<ConfiguredClassHierarchy<EntityClass>> hierarchies = ConfiguredClassHierarchyBuilder.createEntityHierarchies(
|
||||
context
|
||||
|
@ -163,7 +163,7 @@ public class AnnotationBinder implements Binder {
|
|||
for ( EntityClass entityClass : hierarchy ) {
|
||||
// for classes annotated w/ @Entity we create a EntityBinding
|
||||
if ( ConfiguredClassType.ENTITY.equals( entityClass.getConfiguredClassType() ) ) {
|
||||
LOG.bindingEntityFromAnnotatedClass( entityClass.getName() );
|
||||
LOG.debugf( "Binding entity from annotated class: %s", entityClass.getName() );
|
||||
EntityBinder entityBinder = new EntityBinder( metadata, entityClass, parent );
|
||||
EntityBinding binding = entityBinder.bind();
|
||||
parent = binding.getEntity();
|
||||
|
@ -183,7 +183,7 @@ public class AnnotationBinder implements Binder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void bindMappingDependentMetadata(MetadataSources sources) {
|
||||
public void processMappingDependentMetadata(MetadataSources sources) {
|
||||
TableBinder.bind( metadata, index );
|
||||
FetchProfileBinder.bind( metadata, index );
|
||||
QueryBinder.bind( metadata, index );
|
|
@ -23,11 +23,11 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.source.annotations.entity;
|
||||
|
||||
import javax.persistence.GenerationType;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.persistence.GenerationType;
|
||||
|
||||
import org.jboss.jandex.AnnotationInstance;
|
||||
import org.jboss.jandex.AnnotationValue;
|
||||
|
@ -76,7 +76,7 @@ import org.hibernate.metamodel.source.annotations.attribute.state.binding.ManyTo
|
|||
import org.hibernate.metamodel.source.annotations.attribute.state.relational.ColumnRelationalStateImpl;
|
||||
import org.hibernate.metamodel.source.annotations.attribute.state.relational.ManyToOneRelationalStateImpl;
|
||||
import org.hibernate.metamodel.source.annotations.attribute.state.relational.TupleRelationalStateImpl;
|
||||
import org.hibernate.metamodel.source.annotations.entity.state.binding.EntityBindingStateImpl;
|
||||
import org.hibernate.metamodel.source.annotations.entity.state.binding.EntityViewImpl;
|
||||
import org.hibernate.metamodel.source.annotations.global.IdGeneratorBinder;
|
||||
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.metamodel.source.spi.MetadataImplementor;
|
||||
|
@ -100,7 +100,7 @@ public class EntityBinder {
|
|||
|
||||
public EntityBinding bind() {
|
||||
EntityBinding entityBinding = new EntityBinding();
|
||||
EntityBindingStateImpl entityBindingState = new EntityBindingStateImpl( superType, entityClass );
|
||||
EntityViewImpl entityBindingState = new EntityViewImpl( superType, entityClass );
|
||||
|
||||
bindJpaEntityAnnotation( entityBindingState );
|
||||
bindHibernateEntityAnnotation( entityBindingState ); // optional hibernate specific @org.hibernate.annotations.Entity
|
||||
|
@ -201,7 +201,7 @@ public class EntityBinder {
|
|||
bindSingleMappedAttribute( entityBinding, entityBinding.getEntity(), discriminatorAttribute );
|
||||
}
|
||||
|
||||
private void bindWhereFilter(EntityBindingStateImpl entityBindingState) {
|
||||
private void bindWhereFilter(EntityViewImpl entityBindingState) {
|
||||
AnnotationInstance whereAnnotation = JandexHelper.getSingleAnnotation(
|
||||
entityClass.getClassInfo(), HibernateDotNames.WHERE
|
||||
);
|
||||
|
@ -211,7 +211,7 @@ public class EntityBinder {
|
|||
}
|
||||
}
|
||||
|
||||
private void bindHibernateCaching(EntityBindingStateImpl entityBindingState) {
|
||||
private void bindHibernateCaching(EntityViewImpl entityBindingState) {
|
||||
AnnotationInstance cacheAnnotation = JandexHelper.getSingleAnnotation(
|
||||
entityClass.getClassInfo(), HibernateDotNames.CACHE
|
||||
);
|
||||
|
@ -250,7 +250,7 @@ public class EntityBinder {
|
|||
|
||||
// This does not take care of any inheritance of @Cacheable within a class hierarchy as specified in JPA2.
|
||||
// This is currently not supported (HF)
|
||||
private void bindJpaCaching(EntityBindingStateImpl entityBindingState) {
|
||||
private void bindJpaCaching(EntityViewImpl entityBindingState) {
|
||||
AnnotationInstance cacheAnnotation = JandexHelper.getSingleAnnotation(
|
||||
entityClass.getClassInfo(), JPADotNames.CACHEABLE
|
||||
);
|
||||
|
@ -288,7 +288,7 @@ public class EntityBinder {
|
|||
}
|
||||
}
|
||||
|
||||
private void bindProxy(EntityBindingStateImpl entityBindingState) {
|
||||
private void bindProxy(EntityViewImpl entityBindingState) {
|
||||
AnnotationInstance proxyAnnotation = JandexHelper.getSingleAnnotation(
|
||||
entityClass.getClassInfo(), HibernateDotNames.PROXY
|
||||
);
|
||||
|
@ -311,7 +311,7 @@ public class EntityBinder {
|
|||
entityBindingState.setProxyInterfaceName( proxyInterfaceClass );
|
||||
}
|
||||
|
||||
private void bindSynchronize(EntityBindingStateImpl entityBindingState) {
|
||||
private void bindSynchronize(EntityViewImpl entityBindingState) {
|
||||
AnnotationInstance synchronizeAnnotation = JandexHelper.getSingleAnnotation(
|
||||
entityClass.getClassInfo(), HibernateDotNames.SYNCHRONIZE
|
||||
);
|
||||
|
@ -324,7 +324,7 @@ public class EntityBinder {
|
|||
}
|
||||
}
|
||||
|
||||
private void bindCustomSQL(EntityBindingStateImpl entityBindingState) {
|
||||
private void bindCustomSQL(EntityViewImpl entityBindingState) {
|
||||
AnnotationInstance sqlInsertAnnotation = JandexHelper.getSingleAnnotation(
|
||||
entityClass.getClassInfo(), HibernateDotNames.SQL_INSERT
|
||||
);
|
||||
|
@ -373,7 +373,7 @@ public class EntityBinder {
|
|||
);
|
||||
}
|
||||
|
||||
private void bindRowId(EntityBindingStateImpl entityBindingState) {
|
||||
private void bindRowId(EntityViewImpl entityBindingState) {
|
||||
AnnotationInstance rowIdAnnotation = JandexHelper.getSingleAnnotation(
|
||||
entityClass.getClassInfo(), HibernateDotNames.ROW_ID
|
||||
);
|
||||
|
@ -383,7 +383,7 @@ public class EntityBinder {
|
|||
}
|
||||
}
|
||||
|
||||
private void bindBatchSize(EntityBindingStateImpl entityBindingState) {
|
||||
private void bindBatchSize(EntityViewImpl entityBindingState) {
|
||||
AnnotationInstance batchSizeAnnotation = JandexHelper.getSingleAnnotation(
|
||||
entityClass.getClassInfo(), HibernateDotNames.BATCH_SIZE
|
||||
);
|
||||
|
@ -393,7 +393,7 @@ public class EntityBinder {
|
|||
}
|
||||
}
|
||||
|
||||
private Caching createCachingForCacheableAnnotation(EntityBindingStateImpl entityBindingState) {
|
||||
private Caching createCachingForCacheableAnnotation(EntityViewImpl entityBindingState) {
|
||||
String region = entityBindingState.getEntityName();
|
||||
RegionFactory regionFactory = meta.getServiceRegistry().getService( RegionFactory.class );
|
||||
AccessType defaultAccessType = regionFactory.getDefaultAccessType();
|
||||
|
@ -433,11 +433,7 @@ public class EntityBinder {
|
|||
// last, but not least create the metamodel relational objects
|
||||
final Identifier tableNameIdentifier = Identifier.toIdentifier( tableName );
|
||||
final Schema schema = meta.getDatabase().getSchema( new Schema.Name( schemaName, catalogName ) );
|
||||
Table table = schema.getTable( tableNameIdentifier );
|
||||
if ( table == null ) {
|
||||
table = schema.createTable( tableNameIdentifier );
|
||||
}
|
||||
return table;
|
||||
return schema.locateOrCreateTable( tableNameIdentifier );
|
||||
}
|
||||
|
||||
|
||||
|
@ -472,7 +468,8 @@ public class EntityBinder {
|
|||
}
|
||||
}
|
||||
|
||||
private void bindJpaEntityAnnotation(EntityBindingStateImpl entityBindingState) {
|
||||
|
||||
private void bindJpaEntityAnnotation(EntityViewImpl entityBindingState) {
|
||||
AnnotationInstance jpaEntityAnnotation = JandexHelper.getSingleAnnotation(
|
||||
entityClass.getClassInfo(), JPADotNames.ENTITY
|
||||
);
|
||||
|
@ -779,7 +776,7 @@ public class EntityBinder {
|
|||
}
|
||||
}
|
||||
|
||||
private void bindHibernateEntityAnnotation(EntityBindingStateImpl entityBindingState) {
|
||||
private void bindHibernateEntityAnnotation(EntityViewImpl entityBindingState) {
|
||||
// initialize w/ the defaults
|
||||
boolean mutable = true;
|
||||
boolean dynamicInsert = false;
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.hibernate.engine.internal.Versioning;
|
|||
import org.hibernate.metamodel.binding.Caching;
|
||||
import org.hibernate.metamodel.binding.CustomSQL;
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
import org.hibernate.metamodel.binding.state.EntityBindingState;
|
||||
import org.hibernate.metamodel.binder.view.EntityView;
|
||||
import org.hibernate.metamodel.domain.Hierarchical;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EntityClass;
|
||||
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
|
||||
|
@ -43,7 +43,7 @@ import org.hibernate.tuple.entity.EntityTuplizer;
|
|||
/**
|
||||
* @author Hardy Ferentschik
|
||||
*/
|
||||
public class EntityBindingStateImpl implements EntityBindingState {
|
||||
public class EntityViewImpl implements EntityView {
|
||||
private String entityName;
|
||||
|
||||
private final String className;
|
||||
|
@ -78,7 +78,7 @@ public class EntityBindingStateImpl implements EntityBindingState {
|
|||
|
||||
private Set<String> synchronizedTableNames;
|
||||
|
||||
public EntityBindingStateImpl(Hierarchical superType, EntityClass entityClass) {
|
||||
public EntityViewImpl(Hierarchical superType, EntityClass entityClass) {
|
||||
this.className = entityClass.getName();
|
||||
this.superType = superType;
|
||||
this.isRoot = entityClass.isEntityRoot();
|
|
@ -73,7 +73,7 @@ public class TableBinder {
|
|||
String tableName = JandexHelper.getValue( tableAnnotation, "appliesTo", String.class );
|
||||
ObjectName objectName = new ObjectName( tableName );
|
||||
Schema schema = metadata.getDatabase().getSchema( objectName.getSchema(), objectName.getCatalog() );
|
||||
Table table = schema.getTable( objectName.getName() );
|
||||
Table table = schema.locateTable( objectName.getName() );
|
||||
if ( table != null ) {
|
||||
bindHibernateTableAnnotation( table, tableAnnotation );
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.hibernate.AssertionFailure;
|
|||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.metamodel.binder.view.hbm.EntityViewImpl;
|
||||
import org.hibernate.metamodel.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.binding.BagBinding;
|
||||
import org.hibernate.metamodel.binding.CollectionElementType;
|
||||
|
@ -46,7 +47,6 @@ import org.hibernate.metamodel.relational.UniqueKey;
|
|||
import org.hibernate.metamodel.relational.state.ManyToOneRelationalState;
|
||||
import org.hibernate.metamodel.relational.state.TupleRelationalState;
|
||||
import org.hibernate.metamodel.relational.state.ValueRelationalState;
|
||||
import org.hibernate.metamodel.source.hbm.state.binding.HbmEntityBindingState;
|
||||
import org.hibernate.metamodel.source.hbm.state.binding.HbmManyToOneAttributeBindingState;
|
||||
import org.hibernate.metamodel.source.hbm.state.binding.HbmPluralAttributeBindingState;
|
||||
import org.hibernate.metamodel.source.hbm.state.binding.HbmSimpleAttributeBindingState;
|
||||
|
@ -125,7 +125,7 @@ abstract class AbstractEntityBinder {
|
|||
Hierarchical superType) {
|
||||
entityBinding.initialize(
|
||||
bindingContext,
|
||||
new HbmEntityBindingState(
|
||||
new EntityViewImpl(
|
||||
superType,
|
||||
entityClazz,
|
||||
isRoot(),
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
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.XMLHibernateMapping;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class EntityProcessor {
|
||||
private final HbmBindingContext bindingContext;
|
||||
private final EntityBinder entityBinder;
|
||||
|
||||
public EntityProcessor(HbmBindingContext bindingContext) {
|
||||
this.bindingContext = bindingContext;
|
||||
this.entityBinder = new EntityBinder( bindingContext.getMetadataImplementor() );
|
||||
}
|
||||
|
||||
public void process(XMLHibernateMapping.XMLClass xmlClass) {
|
||||
EntityBinding entityBinding = entityBinder.createEntityBinding(
|
||||
new EntityViewImpl(
|
||||
null, // superType
|
||||
xmlClass,
|
||||
true, // isRoot
|
||||
null, // inheritanceType
|
||||
bindingContext
|
||||
)
|
||||
);
|
||||
|
||||
bindingContext.
|
||||
}
|
||||
}
|
|
@ -29,17 +29,17 @@ import java.util.List;
|
|||
import org.hibernate.metamodel.MetadataSources;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping;
|
||||
import org.hibernate.metamodel.source.internal.JaxbRoot;
|
||||
import org.hibernate.metamodel.source.spi.Binder;
|
||||
import org.hibernate.metamodel.source.spi.SourceProcessor;
|
||||
import org.hibernate.metamodel.source.spi.MetadataImplementor;
|
||||
|
||||
/**
|
||||
* Responsible for performing binding of hbm xml.
|
||||
*/
|
||||
public class HbmBinder implements Binder {
|
||||
public class HbmSourceProcessor implements SourceProcessor {
|
||||
private final MetadataImplementor metadata;
|
||||
private List<HibernateMappingProcessor> processors;
|
||||
|
||||
public HbmBinder(MetadataImplementor metadata) {
|
||||
public HbmSourceProcessor(MetadataImplementor metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
|
@ -55,28 +55,28 @@ public class HbmBinder implements Binder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void bindIndependentMetadata(MetadataSources sources) {
|
||||
public void processIndependentMetadata(MetadataSources sources) {
|
||||
for ( HibernateMappingProcessor processor : processors ) {
|
||||
processor.bindIndependentMetadata();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindTypeDependentMetadata(MetadataSources sources) {
|
||||
public void processTypeDependentMetadata(MetadataSources sources) {
|
||||
for ( HibernateMappingProcessor processor : processors ) {
|
||||
processor.bindTypeDependentMetadata();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindMappingMetadata(MetadataSources sources, List<String> processedEntityNames) {
|
||||
public void processMappingMetadata(MetadataSources sources, List<String> processedEntityNames) {
|
||||
for ( HibernateMappingProcessor processor : processors ) {
|
||||
processor.bindMappingMetadata( processedEntityNames );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindMappingDependentMetadata(MetadataSources sources) {
|
||||
public void processMappingDependentMetadata(MetadataSources sources) {
|
||||
for ( HibernateMappingProcessor processor : processors ) {
|
||||
processor.bindMappingDependentMetadata();
|
||||
}
|
|
@ -60,7 +60,7 @@ import org.hibernate.type.Type;
|
|||
/**
|
||||
* Responsible for processing a {@code <hibernate-mapping/>} element. Allows processing to be coordinated across
|
||||
* all hbm files in an ordered fashion. The order is essentially the same as defined in
|
||||
* {@link org.hibernate.metamodel.source.spi.Binder}
|
||||
* {@link org.hibernate.metamodel.source.spi.SourceProcessor}
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -261,6 +261,7 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void bindMappingMetadata(List<String> processedEntityNames) {
|
||||
if ( hibernateMapping.getClazzOrSubclassOrJoinedSubclass() == null ) {
|
||||
return;
|
||||
|
@ -269,7 +270,7 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
if ( XMLHibernateMapping.XMLClass.class.isInstance( clazzOrSubclass ) ) {
|
||||
XMLHibernateMapping.XMLClass clazz =
|
||||
XMLHibernateMapping.XMLClass.class.cast( clazzOrSubclass );
|
||||
new RootEntityBinder( this, clazz ).process( clazz );
|
||||
new RootEntityProcessor( this, clazz ).process( clazz );
|
||||
}
|
||||
else if ( XMLSubclassElement.class.isInstance( clazzOrSubclass ) ) {
|
||||
// PersistentClass superModel = getSuperclass( mappings, element );
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.hibernate.metamodel.domain.Attribute;
|
|||
import org.hibernate.metamodel.relational.Identifier;
|
||||
import org.hibernate.metamodel.relational.InLineView;
|
||||
import org.hibernate.metamodel.relational.Schema;
|
||||
import org.hibernate.metamodel.relational.Table;
|
||||
import org.hibernate.metamodel.relational.state.ValueRelationalState;
|
||||
import org.hibernate.metamodel.source.hbm.state.binding.HbmDiscriminatorBindingState;
|
||||
import org.hibernate.metamodel.source.hbm.state.binding.HbmSimpleAttributeBindingState;
|
||||
|
@ -48,9 +49,9 @@ import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLCla
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
class RootEntityBinder extends AbstractEntityBinder {
|
||||
class RootEntityProcessor extends AbstractEntityBinder {
|
||||
|
||||
RootEntityBinder(HbmBindingContext bindingContext, XMLClass xmlClazz) {
|
||||
RootEntityProcessor(HbmBindingContext bindingContext, XMLClass xmlClazz) {
|
||||
super( bindingContext, xmlClazz );
|
||||
}
|
||||
|
||||
|
@ -98,14 +99,11 @@ class RootEntityBinder extends AbstractEntityBinder {
|
|||
}
|
||||
else {
|
||||
String classTableName = getClassTableName( xmlClazz, entityBinding, null );
|
||||
if(getBindingContext().isGloballyQuotedIdentifiers()){
|
||||
if ( getBindingContext().isGloballyQuotedIdentifiers() ) {
|
||||
classTableName = StringHelper.quote( classTableName );
|
||||
}
|
||||
final Identifier tableName = Identifier.toIdentifier( classTableName );
|
||||
org.hibernate.metamodel.relational.Table table = schema.getTable( tableName );
|
||||
if ( table == null ) {
|
||||
table = schema.createTable( tableName );
|
||||
}
|
||||
final Table table = schema.locateOrCreateTable( tableName );
|
||||
entityBinding.setBaseTable( table );
|
||||
String comment = xmlClazz.getComment();
|
||||
if ( comment != null ) {
|
|
@ -53,12 +53,13 @@ import org.hibernate.metamodel.binding.PluralAttributeBinding;
|
|||
import org.hibernate.metamodel.binding.TypeDef;
|
||||
import org.hibernate.metamodel.domain.JavaType;
|
||||
import org.hibernate.metamodel.relational.Database;
|
||||
import org.hibernate.metamodel.source.annotations.AnnotationBinder;
|
||||
import org.hibernate.metamodel.source.hbm.HbmBinder;
|
||||
import org.hibernate.metamodel.source.spi.Binder;
|
||||
import org.hibernate.metamodel.source.annotations.AnnotationSourceProcessor;
|
||||
import org.hibernate.metamodel.source.hbm.HbmSourceProcessor;
|
||||
import org.hibernate.metamodel.source.spi.MappingDefaults;
|
||||
import org.hibernate.metamodel.source.spi.MetaAttributeContext;
|
||||
import org.hibernate.metamodel.source.spi.MetadataImplementor;
|
||||
import org.hibernate.metamodel.source.spi.SourceProcessor;
|
||||
import org.hibernate.persister.spi.PersisterClassResolver;
|
||||
import org.hibernate.service.BasicServiceRegistry;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.type.Type;
|
||||
|
@ -80,7 +81,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
|
||||
private final BasicServiceRegistry serviceRegistry;
|
||||
private final Options options;
|
||||
private ClassLoaderService classLoaderService;
|
||||
private final org.hibernate.internal.util.Value<ClassLoaderService> classLoaderService;
|
||||
|
||||
private TypeResolver typeResolver = new TypeResolver();
|
||||
|
||||
|
@ -115,60 +116,78 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
|
||||
this.mappingDefaults = new MappingDefaultsImpl();
|
||||
|
||||
final Binder[] binders;
|
||||
final SourceProcessor[] sourceProcessors;
|
||||
if ( options.getSourceProcessingOrder() == SourceProcessingOrder.HBM_FIRST ) {
|
||||
binders = new Binder[] {
|
||||
new HbmBinder( this ),
|
||||
new AnnotationBinder( this )
|
||||
sourceProcessors = new SourceProcessor[] {
|
||||
new HbmSourceProcessor( this ),
|
||||
new AnnotationSourceProcessor( this )
|
||||
};
|
||||
}
|
||||
else {
|
||||
binders = new Binder[] {
|
||||
new AnnotationBinder( this ),
|
||||
new HbmBinder( this )
|
||||
sourceProcessors = new SourceProcessor[] {
|
||||
new AnnotationSourceProcessor( this ),
|
||||
new HbmSourceProcessor( this )
|
||||
};
|
||||
}
|
||||
|
||||
this.classLoaderService = new org.hibernate.internal.util.Value<ClassLoaderService>(
|
||||
new org.hibernate.internal.util.Value.DeferredInitializer<ClassLoaderService>() {
|
||||
@Override
|
||||
public ClassLoaderService initialize() {
|
||||
return serviceRegistry.getService( ClassLoaderService.class );
|
||||
}
|
||||
}
|
||||
);
|
||||
this.persisterClassResolverService = new org.hibernate.internal.util.Value<PersisterClassResolver>(
|
||||
new org.hibernate.internal.util.Value.DeferredInitializer<PersisterClassResolver>() {
|
||||
@Override
|
||||
public PersisterClassResolver initialize() {
|
||||
return serviceRegistry.getService( PersisterClassResolver.class );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
final ArrayList<String> processedEntityNames = new ArrayList<String>();
|
||||
|
||||
prepare( binders, metadataSources );
|
||||
bindIndependentMetadata( binders, metadataSources );
|
||||
bindTypeDependentMetadata( binders, metadataSources );
|
||||
bindMappingMetadata( binders, metadataSources, processedEntityNames );
|
||||
bindMappingDependentMetadata( binders, metadataSources );
|
||||
prepare( sourceProcessors, metadataSources );
|
||||
bindIndependentMetadata( sourceProcessors, metadataSources );
|
||||
bindTypeDependentMetadata( sourceProcessors, metadataSources );
|
||||
bindMappingMetadata( sourceProcessors, metadataSources, processedEntityNames );
|
||||
bindMappingDependentMetadata( sourceProcessors, metadataSources );
|
||||
|
||||
// todo : remove this by coordinated ordering of entity processing
|
||||
new EntityReferenceResolver( this ).resolve();
|
||||
new AttributeTypeResolver( this ).resolve();
|
||||
}
|
||||
|
||||
private void prepare(Binder[] binders, MetadataSources metadataSources) {
|
||||
for ( Binder binder : binders ) {
|
||||
binder.prepare( metadataSources );
|
||||
private void prepare(SourceProcessor[] sourceProcessors, MetadataSources metadataSources) {
|
||||
for ( SourceProcessor sourceProcessor : sourceProcessors ) {
|
||||
sourceProcessor.prepare( metadataSources );
|
||||
}
|
||||
}
|
||||
|
||||
private void bindIndependentMetadata(Binder[] binders, MetadataSources metadataSources) {
|
||||
for ( Binder binder : binders ) {
|
||||
binder.bindIndependentMetadata( metadataSources );
|
||||
private void bindIndependentMetadata(SourceProcessor[] sourceProcessors, MetadataSources metadataSources) {
|
||||
for ( SourceProcessor sourceProcessor : sourceProcessors ) {
|
||||
sourceProcessor.processIndependentMetadata( metadataSources );
|
||||
}
|
||||
}
|
||||
|
||||
private void bindTypeDependentMetadata(Binder[] binders, MetadataSources metadataSources) {
|
||||
for ( Binder binder : binders ) {
|
||||
binder.bindTypeDependentMetadata( metadataSources );
|
||||
private void bindTypeDependentMetadata(SourceProcessor[] sourceProcessors, MetadataSources metadataSources) {
|
||||
for ( SourceProcessor sourceProcessor : sourceProcessors ) {
|
||||
sourceProcessor.processTypeDependentMetadata( metadataSources );
|
||||
}
|
||||
}
|
||||
|
||||
private void bindMappingMetadata(Binder[] binders, MetadataSources metadataSources, List<String> processedEntityNames) {
|
||||
for ( Binder binder : binders ) {
|
||||
binder.bindMappingMetadata( metadataSources, processedEntityNames );
|
||||
private void bindMappingMetadata(SourceProcessor[] sourceProcessors, MetadataSources metadataSources, List<String> processedEntityNames) {
|
||||
for ( SourceProcessor sourceProcessor : sourceProcessors ) {
|
||||
sourceProcessor.processMappingMetadata( metadataSources, processedEntityNames );
|
||||
}
|
||||
}
|
||||
|
||||
private void bindMappingDependentMetadata(Binder[] binders, MetadataSources metadataSources) {
|
||||
for ( Binder binder : binders ) {
|
||||
binder.bindMappingDependentMetadata( metadataSources );
|
||||
private void bindMappingDependentMetadata(SourceProcessor[] sourceProcessors, MetadataSources metadataSources) {
|
||||
for ( SourceProcessor sourceProcessor : sourceProcessors ) {
|
||||
sourceProcessor.processMappingDependentMetadata( metadataSources );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -285,11 +304,12 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
return typeDefs.get( name );
|
||||
}
|
||||
|
||||
private ClassLoaderService classLoaderService(){
|
||||
if(classLoaderService==null){
|
||||
classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||
}
|
||||
return classLoaderService;
|
||||
private ClassLoaderService classLoaderService() {
|
||||
return classLoaderService.getValue();
|
||||
}
|
||||
|
||||
private PersisterClassResolver persisterClassResolverService() {
|
||||
return persisterClassResolverService.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,7 +24,9 @@
|
|||
package org.hibernate.metamodel.source.spi;
|
||||
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.metamodel.binder.view.EntityView;
|
||||
import org.hibernate.metamodel.domain.JavaType;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.hibernate.engine.spi.Mapping;
|
|||
import org.hibernate.engine.spi.NamedQueryDefinition;
|
||||
import org.hibernate.engine.spi.NamedSQLQueryDefinition;
|
||||
import org.hibernate.metamodel.Metadata;
|
||||
import org.hibernate.metamodel.SessionFactoryBuilder;
|
||||
import org.hibernate.metamodel.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.binding.FetchProfile;
|
||||
import org.hibernate.metamodel.binding.IdGenerator;
|
||||
|
@ -71,4 +70,9 @@ public interface MetadataImplementor extends Metadata, BindingContext, Mapping {
|
|||
public void addNamedQuery(NamedQueryDefinition def);
|
||||
|
||||
public void addResultSetMapping(ResultSetMappingDefinition resultSetMappingDefinition);
|
||||
|
||||
public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject);
|
||||
|
||||
// todo : this needs to move to AnnotationBindingContext
|
||||
public void setGloballyQuotedIdentifiers(boolean b);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* 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.List;
|
||||
|
||||
import org.hibernate.metamodel.MetadataSources;
|
||||
|
||||
/**
|
||||
* Handles the processing of metadata sources in a dependency-ordered manner.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SourceProcessor {
|
||||
/**
|
||||
* Prepare for processing the given sources.
|
||||
*
|
||||
* @param sources The metadata sources.
|
||||
*/
|
||||
public void prepare(MetadataSources sources);
|
||||
|
||||
/**
|
||||
* Process the independent metadata. These have no dependency on other types of metadata being processed.
|
||||
*
|
||||
* @param sources The metadata sources.
|
||||
*
|
||||
* @see #prepare
|
||||
*/
|
||||
public void processIndependentMetadata(MetadataSources sources);
|
||||
|
||||
/**
|
||||
* Process the parts of the metadata that depend on type information (type definitions) having been processed
|
||||
* and available.
|
||||
*
|
||||
* @param sources The metadata sources.
|
||||
*
|
||||
* @see #processIndependentMetadata
|
||||
*/
|
||||
public void processTypeDependentMetadata(MetadataSources sources);
|
||||
|
||||
/**
|
||||
* Process the mapping (entities, et al) metadata.
|
||||
*
|
||||
* @param sources The metadata sources.
|
||||
* @param processedEntityNames Collection of any already processed entity names.
|
||||
*
|
||||
* @see #processTypeDependentMetadata
|
||||
*/
|
||||
public void processMappingMetadata(MetadataSources sources, List<String> processedEntityNames);
|
||||
|
||||
/**
|
||||
* Process the parts of the metadata that depend on mapping (entities, et al) information having been
|
||||
* processed and available.
|
||||
*
|
||||
* @param sources The metadata sources.
|
||||
*
|
||||
* @see #processMappingMetadata
|
||||
*/
|
||||
public void processMappingDependentMetadata(MetadataSources sources);
|
||||
}
|
|
@ -136,7 +136,7 @@ public final class PersisterFactoryImpl implements PersisterFactory, ServiceRegi
|
|||
EntityRegionAccessStrategy cacheAccessStrategy,
|
||||
SessionFactoryImplementor factory,
|
||||
Mapping cfg) {
|
||||
Class<? extends EntityPersister> persisterClass = metadata.getEntityPersisterClass();
|
||||
Class<? extends EntityPersister> persisterClass = metadata.getCustomEntityPersisterClass();
|
||||
if ( persisterClass == null ) {
|
||||
persisterClass = serviceRegistry.getService( PersisterClassResolver.class ).getEntityPersisterClass( metadata );
|
||||
}
|
||||
|
|
|
@ -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.getEntityTuplizerClass();
|
||||
Class<EntityTuplizer> tuplizerClass = entityBinding.getCustomEntityTuplizerClass();
|
||||
|
||||
if ( tuplizerClass == null ) {
|
||||
entityTuplizer = entityTuplizerFactory.constructDefaultTuplizer( entityMode, this, entityBinding );
|
||||
|
|
|
@ -34,7 +34,7 @@ public class MultiplePK implements Serializable
|
|||
private final Long id1;
|
||||
private final Long id2;
|
||||
private final Long id3;
|
||||
// AnnotationBinder (incorrectly) requires this to be transient; see HHH-4819 and HHH-4820
|
||||
// AnnotationSourceProcessor (incorrectly) requires this to be transient; see HHH-4819 and HHH-4820
|
||||
private final transient int cachedHashCode;
|
||||
|
||||
private MultiplePK()
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<!-- Mapping document mainly used for testing non-reflective Binder + meta inheritance -->
|
||||
<!-- Mapping document mainly used for testing non-reflective SourceProcessor + meta inheritance -->
|
||||
<hibernate-mapping default-lazy="false">
|
||||
<meta attribute="global">global value</meta>
|
||||
<meta attribute="globalnoinherit" inherit="false">only visible at top level</meta>
|
||||
|
|
Loading…
Reference in New Issue