HHH-6371 - Develop metamodel binding creation using a push approach
This commit is contained in:
parent
594f689d98
commit
66bd796063
|
@ -41,6 +41,11 @@ import org.hibernate.metamodel.domain.JavaType;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class EntityBinder {
|
||||
|
||||
// todo : re-purpose this as a general "metadata binder" with public apis to handle all the specific bindings?
|
||||
|
||||
// todo : make this globally available from MetadataImpl
|
||||
|
||||
private final BindingContext bindingContext;
|
||||
|
||||
public EntityBinder(BindingContext bindingContext) {
|
||||
|
|
|
@ -37,9 +37,7 @@ public interface BindingContext {
|
|||
|
||||
public MappingDefaults getMappingDefaults();
|
||||
|
||||
public MetaAttributeContext getMetaAttributeContext();
|
||||
|
||||
public MetadataImplementor getMetadataImplementor();
|
||||
public MetadataImplementor getMetadataImplementor();
|
||||
|
||||
public <T> Class<T> locateClassByName(String name);
|
||||
|
||||
|
|
|
@ -23,12 +23,14 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.binder.source;
|
||||
|
||||
import org.hibernate.cache.spi.access.AccessType;
|
||||
|
||||
/**
|
||||
* Defines a (contextual) set of values to use as defaults in the absence of related mapping information. The
|
||||
* context here is conceptually a stack. The "global" level is configuration settings.
|
||||
*
|
||||
* @author Gail Badner
|
||||
* @author Steve Ebersole
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public interface MappingDefaults {
|
||||
/**
|
||||
|
@ -89,4 +91,11 @@ public interface MappingDefaults {
|
|||
* @return The default association laziness
|
||||
*/
|
||||
public boolean areAssociationsLazy();
|
||||
|
||||
/**
|
||||
* The default cache access type to use
|
||||
*
|
||||
* @return The default cache access type.
|
||||
*/
|
||||
public AccessType getCacheAccessType();
|
||||
}
|
||||
|
|
|
@ -75,4 +75,6 @@ public interface MetadataImplementor extends Metadata, BindingContext, Mapping {
|
|||
|
||||
// todo : this needs to move to AnnotationBindingContext
|
||||
public void setGloballyQuotedIdentifiers(boolean b);
|
||||
|
||||
public MetaAttributeContext getGlobalMetaAttributeContext();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.binder.source;
|
||||
|
||||
import org.hibernate.annotations.OptimisticLockType;
|
||||
import org.hibernate.engine.OptimisticLockStyle;
|
||||
import org.hibernate.metamodel.binding.Caching;
|
||||
|
||||
|
|
|
@ -0,0 +1,358 @@
|
|||
/*
|
||||
* 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.source.annotations;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jboss.jandex.AnnotationInstance;
|
||||
import org.jboss.jandex.AnnotationValue;
|
||||
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.annotations.ResultCheckStyle;
|
||||
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
|
||||
import org.hibernate.metamodel.binder.Origin;
|
||||
import org.hibernate.metamodel.binder.source.EntityDescriptor;
|
||||
import org.hibernate.metamodel.binder.source.MetaAttributeContext;
|
||||
import org.hibernate.metamodel.binder.source.UnifiedDescriptorObject;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClass;
|
||||
import org.hibernate.metamodel.binding.CustomSQL;
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.tuple.entity.EntityTuplizer;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractEntityDescriptorImpl implements EntityDescriptor {
|
||||
private final ConfiguredClass configuredClass;
|
||||
@SuppressWarnings( {"FieldCanBeLocal", "UnusedDeclaration"}) // for now this is not used.
|
||||
private final AnnotationsBindingContext bindingContext;
|
||||
|
||||
private final String jpaEntityName;
|
||||
|
||||
private final String superEntityName;
|
||||
private final InheritanceType inheritanceType;
|
||||
|
||||
private final boolean lazy;
|
||||
private final String proxyInterfaceName;
|
||||
|
||||
private final Class<EntityPersister> entityPersisterClass;
|
||||
private final Class<EntityTuplizer> tuplizerClass;
|
||||
|
||||
private final int batchSize;
|
||||
|
||||
private final boolean dynamicUpdate;
|
||||
private final boolean dynamicInsert;
|
||||
|
||||
private final boolean selectBeforeUpdate;
|
||||
|
||||
private final String customLoaderName;
|
||||
private final CustomSQL customInsert;
|
||||
private final CustomSQL customUpdate;
|
||||
private final CustomSQL customDelete;
|
||||
|
||||
private final Set<String> synchronizedTableNames;
|
||||
|
||||
public AbstractEntityDescriptorImpl(
|
||||
ConfiguredClass configuredClass,
|
||||
String superEntityName,
|
||||
InheritanceType inheritanceType,
|
||||
AnnotationsBindingContext bindingContext) {
|
||||
this.configuredClass = configuredClass;
|
||||
this.superEntityName = superEntityName;
|
||||
this.inheritanceType = inheritanceType;
|
||||
this.bindingContext = bindingContext;
|
||||
|
||||
final AnnotationInstance jpaEntityAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), JPADotNames.ENTITY
|
||||
);
|
||||
|
||||
final AnnotationValue explicitJpaEntityName = jpaEntityAnnotation.value( "name" );
|
||||
if ( explicitJpaEntityName == null ) {
|
||||
jpaEntityName = configuredClass.getName();
|
||||
}
|
||||
else {
|
||||
jpaEntityName = explicitJpaEntityName.asString();
|
||||
}
|
||||
|
||||
final AnnotationInstance hibernateEntityAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), HibernateDotNames.ENTITY
|
||||
);
|
||||
|
||||
this.dynamicInsert = hibernateEntityAnnotation != null
|
||||
&& hibernateEntityAnnotation.value( "dynamicInsert" ) != null
|
||||
&& hibernateEntityAnnotation.value( "dynamicInsert" ).asBoolean();
|
||||
|
||||
this.dynamicUpdate = hibernateEntityAnnotation != null
|
||||
&& hibernateEntityAnnotation.value( "dynamicUpdate" ) != null
|
||||
&& hibernateEntityAnnotation.value( "dynamicUpdate" ).asBoolean();
|
||||
|
||||
this.selectBeforeUpdate = hibernateEntityAnnotation != null
|
||||
&& hibernateEntityAnnotation.value( "selectBeforeUpdate" ) != null
|
||||
&& hibernateEntityAnnotation.value( "selectBeforeUpdate" ).asBoolean();
|
||||
|
||||
final AnnotationInstance sqlLoaderAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), HibernateDotNames.LOADER
|
||||
);
|
||||
this.customLoaderName = sqlLoaderAnnotation == null
|
||||
? null
|
||||
: sqlLoaderAnnotation.value( "namedQuery" ).asString();
|
||||
final AnnotationInstance sqlInsertAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), HibernateDotNames.SQL_INSERT
|
||||
);
|
||||
this.customInsert = createCustomSQL( sqlInsertAnnotation );
|
||||
final AnnotationInstance sqlUpdateAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), HibernateDotNames.SQL_UPDATE
|
||||
);
|
||||
this.customUpdate = createCustomSQL( sqlUpdateAnnotation );
|
||||
final AnnotationInstance sqlDeleteAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), HibernateDotNames.SQL_DELETE
|
||||
);
|
||||
this.customDelete = createCustomSQL( sqlDeleteAnnotation );
|
||||
|
||||
final AnnotationInstance batchSizeAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), HibernateDotNames.BATCH_SIZE
|
||||
);
|
||||
this.batchSize = batchSizeAnnotation == null
|
||||
? -1
|
||||
: batchSizeAnnotation.value( "size" ).asInt();
|
||||
|
||||
final AnnotationInstance hibernateProxyAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), HibernateDotNames.PROXY
|
||||
);
|
||||
if ( hibernateProxyAnnotation != null ) {
|
||||
this.lazy = hibernateProxyAnnotation.value( "lazy" ) == null
|
||||
|| hibernateProxyAnnotation.value( "lazy" ).asBoolean();
|
||||
final AnnotationValue proxyClassValue = hibernateProxyAnnotation.value( "proxyClass" );
|
||||
if ( proxyClassValue == null ) {
|
||||
this.proxyInterfaceName = null;
|
||||
}
|
||||
else {
|
||||
this.proxyInterfaceName = bindingContext.locateClassByName( proxyClassValue.asString() ).getName();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.lazy = true;
|
||||
this.proxyInterfaceName = configuredClass.getName();
|
||||
}
|
||||
|
||||
final AnnotationInstance persisterAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), HibernateDotNames.PERSISTER
|
||||
);
|
||||
if ( persisterAnnotation == null || persisterAnnotation.value( "impl" ) == null ) {
|
||||
if ( hibernateEntityAnnotation != null && hibernateEntityAnnotation.value( "persister" ) != null ) {
|
||||
this.entityPersisterClass = bindingContext.locateClassByName( hibernateEntityAnnotation.value( "persister" ).asString() );
|
||||
}
|
||||
else {
|
||||
this.entityPersisterClass = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( hibernateEntityAnnotation != null && hibernateEntityAnnotation.value( "persister" ) != null ) {
|
||||
// todo : error?
|
||||
}
|
||||
this.entityPersisterClass = bindingContext.locateClassByName( persisterAnnotation.value( "impl" ).asString() );
|
||||
}
|
||||
|
||||
final AnnotationInstance pojoTuplizerAnnotation = locatePojoTuplizerAnnotation();
|
||||
if ( pojoTuplizerAnnotation == null ) {
|
||||
tuplizerClass = null;
|
||||
}
|
||||
else {
|
||||
tuplizerClass = bindingContext.locateClassByName( pojoTuplizerAnnotation.value( "impl" ).asString() );
|
||||
}
|
||||
|
||||
final AnnotationInstance synchronizeAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), HibernateDotNames.SYNCHRONIZE
|
||||
);
|
||||
if ( synchronizeAnnotation != null ) {
|
||||
synchronizedTableNames = new HashSet<String>();
|
||||
final String[] tableNames = synchronizeAnnotation.value().asStringArray();
|
||||
synchronizedTableNames.addAll( Arrays.asList( tableNames ) );
|
||||
}
|
||||
else {
|
||||
synchronizedTableNames = java.util.Collections.emptySet();
|
||||
}
|
||||
}
|
||||
|
||||
private CustomSQL createCustomSQL(AnnotationInstance customSQLAnnotation) {
|
||||
if ( customSQLAnnotation == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String sql = customSQLAnnotation.value( "sql" ).asString();
|
||||
boolean isCallable = false;
|
||||
AnnotationValue callableValue = customSQLAnnotation.value( "callable" );
|
||||
if ( callableValue != null ) {
|
||||
isCallable = callableValue.asBoolean();
|
||||
}
|
||||
|
||||
ResultCheckStyle checkStyle = ResultCheckStyle.NONE;
|
||||
AnnotationValue checkStyleValue = customSQLAnnotation.value( "check" );
|
||||
if ( checkStyleValue != null ) {
|
||||
checkStyle = Enum.valueOf( ResultCheckStyle.class, checkStyleValue.asEnum() );
|
||||
}
|
||||
|
||||
return new CustomSQL(
|
||||
sql,
|
||||
isCallable,
|
||||
Enum.valueOf( ExecuteUpdateResultCheckStyle.class, checkStyle.toString() )
|
||||
);
|
||||
}
|
||||
|
||||
private AnnotationInstance locatePojoTuplizerAnnotation() {
|
||||
final AnnotationInstance tuplizersAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), HibernateDotNames.SYNCHRONIZE
|
||||
);
|
||||
if ( tuplizersAnnotation == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for ( AnnotationInstance tuplizerAnnotation : JandexHelper.getValueAsArray(tuplizersAnnotation, "value" ) ) {
|
||||
if ( EntityMode.valueOf( tuplizerAnnotation.value( "entityModeType" ).asEnum() ) == EntityMode.POJO ) {
|
||||
return tuplizerAnnotation;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return configuredClass.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityName() {
|
||||
return getClassName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJpaEntityName() {
|
||||
return jpaEntityName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityMode getEntityMode() {
|
||||
return EntityMode.POJO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProxyInterfaceName() {
|
||||
return proxyInterfaceName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<EntityPersister> getCustomEntityPersisterClass() {
|
||||
return entityPersisterClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<EntityTuplizer> getCustomEntityTuplizerClass() {
|
||||
return tuplizerClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuperEntityName() {
|
||||
return superEntityName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InheritanceType getEntityInheritanceType() {
|
||||
return inheritanceType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaAttributeContext getMetaAttributeContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLazy() {
|
||||
return lazy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDynamicUpdate() {
|
||||
return dynamicUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDynamicInsert() {
|
||||
return dynamicInsert;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatchSize() {
|
||||
return batchSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelectBeforeUpdate() {
|
||||
return selectBeforeUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isAbstract() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomLoaderName() {
|
||||
return customLoaderName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomSQL getCustomInsert() {
|
||||
return customInsert;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomSQL getCustomUpdate() {
|
||||
return customUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomSQL getCustomDelete() {
|
||||
return customDelete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getSynchronizedTableNames() {
|
||||
return synchronizedTableNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnifiedDescriptorObject getContainingDescriptor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Origin getOrigin() {
|
||||
// return bindingContext.getOrigin();
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -21,25 +21,24 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.testing.junit4;
|
||||
package org.hibernate.metamodel.binder.source.annotations;
|
||||
|
||||
import com.fasterxml.classmate.ResolvedType;
|
||||
import com.fasterxml.classmate.ResolvedTypeWithMembers;
|
||||
import org.jboss.jandex.ClassInfo;
|
||||
import org.jboss.jandex.Index;
|
||||
|
||||
import org.hibernate.metamodel.binder.source.BindingContext;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class SkipMarker {
|
||||
private final String testName;
|
||||
private final String reason;
|
||||
public interface AnnotationsBindingContext extends BindingContext {
|
||||
public Index getIndex();
|
||||
public ClassInfo getClassInfo(String name);
|
||||
|
||||
public SkipMarker(String testName, String reason) {
|
||||
this.testName = testName;
|
||||
this.reason = reason;
|
||||
}
|
||||
public void resolveAllTypes(String className);
|
||||
public ResolvedType getResolvedType(Class<?> clazz);
|
||||
|
||||
public String getTestName() {
|
||||
return testName;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
public ResolvedTypeWithMembers resolveMemberTypes(ResolvedType type);
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* 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.source.annotations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jboss.jandex.AnnotationInstance;
|
||||
import org.jboss.jandex.AnnotationValue;
|
||||
import org.jboss.jandex.Index;
|
||||
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.metamodel.binder.MappingException;
|
||||
import org.hibernate.metamodel.binder.source.EntityDescriptor;
|
||||
import org.hibernate.metamodel.binder.source.MappingDefaults;
|
||||
import org.hibernate.metamodel.binder.source.MetadataImplementor;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClass;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.EntityBinder;
|
||||
import org.hibernate.metamodel.binder.source.internal.OverriddenMappingDefaults;
|
||||
import org.hibernate.metamodel.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.domain.JavaType;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* @author Hardy Ferentschik
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class AnnotationsMetadataProcessor implements AnnotationsBindingContext {
|
||||
private final AnnotationsBindingContext parentBindingContext;
|
||||
private final ConfiguredClass configuredClass;
|
||||
|
||||
private final MappingDefaults mappingDefaults;
|
||||
|
||||
private final org.hibernate.metamodel.binder.EntityBinder entityBinder;
|
||||
|
||||
public AnnotationsMetadataProcessor(
|
||||
AnnotationsBindingContext parentBindingContext,
|
||||
ConfiguredClass configuredClass) {
|
||||
this.parentBindingContext = parentBindingContext;
|
||||
this.configuredClass = configuredClass;
|
||||
|
||||
String explicitSchemaName = null;
|
||||
String explicitCatalogName = null;
|
||||
AnnotationInstance tableAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(),
|
||||
JPADotNames.TABLE
|
||||
);
|
||||
if ( tableAnnotation != null ) {
|
||||
AnnotationValue schemaValue = tableAnnotation.value( "schema" );
|
||||
explicitSchemaName = schemaValue != null ? schemaValue.asString() : null;
|
||||
AnnotationValue catalogValue = tableAnnotation.value( "catalog" );
|
||||
explicitCatalogName = catalogValue != null ? catalogValue.asString() : null;
|
||||
}
|
||||
this.mappingDefaults = new OverriddenMappingDefaults(
|
||||
parentBindingContext.getMappingDefaults(),
|
||||
null, // packageName
|
||||
explicitSchemaName,
|
||||
explicitCatalogName,
|
||||
null, // idColumnName
|
||||
null, // discriminatorColumnName
|
||||
null, // cascade
|
||||
null, // property accessor
|
||||
null // association laziness
|
||||
);
|
||||
|
||||
this.entityBinder = new org.hibernate.metamodel.binder.EntityBinder( this );
|
||||
}
|
||||
|
||||
|
||||
public void processMappingMetadata(List<String> processedEntityNames) {
|
||||
final EntityDescriptor entityDescriptor;
|
||||
switch ( configuredClass.getInheritanceType() ) {
|
||||
case NO_INHERITANCE: {
|
||||
entityDescriptor = new RootEntityDescriptorImpl( configuredClass, this );
|
||||
break;
|
||||
}
|
||||
// else if ( XMLSubclassElement.class.isInstance( entityElement ) ) {
|
||||
// entityDescriptor = new DiscriminatedSubClassEntityDescriptorImpl( entityElement, this );
|
||||
// }
|
||||
// else if ( XMLJoinedSubclassElement.class.isInstance( entityElement ) ) {
|
||||
// entityDescriptor = new JoinedSubClassEntityDescriptorImpl( entityElement, this );
|
||||
// }
|
||||
// else if ( XMLUnionSubclassElement.class.isInstance( entityElement ) ) {
|
||||
// entityDescriptor = new UnionSubClassEntityDescriptorImpl( entityElement, this );
|
||||
// }
|
||||
default: {
|
||||
throw new MappingException(
|
||||
"unknown type of class or subclass: " + configuredClass.getName(),
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( processedEntityNames.contains( configuredClass.getName() ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
final EntityBinding entityBinding = entityBinder.createEntityBinding( entityDescriptor );
|
||||
getMetadataImplementor().addEntity( entityBinding );
|
||||
processedEntityNames.add( configuredClass.getName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Index getIndex() {
|
||||
return parentBindingContext.getIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceRegistry getServiceRegistry() {
|
||||
return parentBindingContext.getServiceRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamingStrategy getNamingStrategy() {
|
||||
return parentBindingContext.getNamingStrategy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MappingDefaults getMappingDefaults() {
|
||||
return mappingDefaults;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataImplementor getMetadataImplementor() {
|
||||
return parentBindingContext.getMetadataImplementor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Class<T> locateClassByName(String name) {
|
||||
return parentBindingContext.locateClassByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaType makeJavaType(String className) {
|
||||
return parentBindingContext.makeJavaType( className );
|
||||
}
|
||||
}
|
|
@ -21,43 +21,54 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations;
|
||||
package org.hibernate.metamodel.binder.source.annotations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.fasterxml.classmate.MemberResolver;
|
||||
import com.fasterxml.classmate.ResolvedType;
|
||||
import com.fasterxml.classmate.ResolvedTypeWithMembers;
|
||||
import com.fasterxml.classmate.TypeResolver;
|
||||
import org.jboss.jandex.ClassInfo;
|
||||
import org.jboss.jandex.DotName;
|
||||
import org.jboss.jandex.Index;
|
||||
import org.jboss.jandex.Indexer;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.internal.util.Value;
|
||||
import org.hibernate.metamodel.MetadataSources;
|
||||
import org.hibernate.metamodel.binder.source.MappingDefaults;
|
||||
import org.hibernate.metamodel.binder.source.MetadataImplementor;
|
||||
import org.hibernate.metamodel.binder.source.SourceProcessor;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClassHierarchy;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClassType;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.EntityBinder;
|
||||
import org.hibernate.metamodel.binder.source.annotations.global.FetchProfileBinder;
|
||||
import org.hibernate.metamodel.binder.source.annotations.global.FilterDefBinder;
|
||||
import org.hibernate.metamodel.binder.source.annotations.global.IdGeneratorBinder;
|
||||
import org.hibernate.metamodel.binder.source.annotations.global.QueryBinder;
|
||||
import org.hibernate.metamodel.binder.source.annotations.global.TableBinder;
|
||||
import org.hibernate.metamodel.binder.source.annotations.global.TypeDefBinder;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.PseudoJpaDotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.EntityMappingsMocker;
|
||||
import org.hibernate.metamodel.binder.source.internal.JaxbRoot;
|
||||
import org.hibernate.metamodel.binder.source.internal.MetadataImpl;
|
||||
import org.hibernate.metamodel.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.domain.Hierarchical;
|
||||
import org.hibernate.metamodel.domain.JavaType;
|
||||
import org.hibernate.metamodel.domain.NonEntity;
|
||||
import org.hibernate.metamodel.domain.Superclass;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLEntityMappings;
|
||||
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClassHierarchy;
|
||||
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClassType;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EntityBinder;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EntityClass;
|
||||
import org.hibernate.metamodel.source.annotations.global.FetchProfileBinder;
|
||||
import org.hibernate.metamodel.source.annotations.global.FilterDefBinder;
|
||||
import org.hibernate.metamodel.source.annotations.global.IdGeneratorBinder;
|
||||
import org.hibernate.metamodel.source.annotations.global.QueryBinder;
|
||||
import org.hibernate.metamodel.source.annotations.global.TableBinder;
|
||||
import org.hibernate.metamodel.source.annotations.global.TypeDefBinder;
|
||||
import org.hibernate.metamodel.source.annotations.util.ConfiguredClassHierarchyBuilder;
|
||||
import org.hibernate.metamodel.source.annotations.xml.OrmXmlParser;
|
||||
import org.hibernate.metamodel.binder.source.internal.JaxbRoot;
|
||||
import org.hibernate.metamodel.source.annotations.xml.PseudoJpaDotNames;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
|
||||
/**
|
||||
|
@ -66,23 +77,26 @@ import org.hibernate.service.classloading.spi.ClassLoaderService;
|
|||
* and pseudo annotations are created.
|
||||
*
|
||||
* @author Hardy Ferentschik
|
||||
* @see org.hibernate.metamodel.source.annotations.xml.OrmXmlParser
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class AnnotationSourceProcessor implements SourceProcessor {
|
||||
private static final Logger LOG = Logger.getLogger( AnnotationSourceProcessor.class );
|
||||
public class AnnotationsSourceProcessor implements SourceProcessor, AnnotationsBindingContext {
|
||||
private static final Logger LOG = Logger.getLogger( AnnotationsSourceProcessor.class );
|
||||
|
||||
private final MetadataImplementor metadata;
|
||||
private final Value<ClassLoaderService> classLoaderService;
|
||||
|
||||
private Index index;
|
||||
|
||||
public AnnotationSourceProcessor(MetadataImpl metadata) {
|
||||
private final TypeResolver typeResolver = new TypeResolver();
|
||||
private final Map<Class<?>, ResolvedType> resolvedTypeCache = new HashMap<Class<?>, ResolvedType>();
|
||||
|
||||
public AnnotationsSourceProcessor(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 );
|
||||
return AnnotationsSourceProcessor.this.metadata.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -111,9 +125,7 @@ public class AnnotationSourceProcessor implements SourceProcessor {
|
|||
}
|
||||
}
|
||||
if ( !mappings.isEmpty() ) {
|
||||
// process the xml configuration
|
||||
final OrmXmlParser ormParser = new OrmXmlParser( metadata );
|
||||
index = ormParser.parseAndUpdateIndex( mappings, index );
|
||||
index = parseAndUpdateIndex( mappings, index );
|
||||
}
|
||||
|
||||
if( index.getAnnotations( PseudoJpaDotNames.DEFAULT_DELIMITED_IDENTIFIERS ) != null ) {
|
||||
|
@ -122,12 +134,14 @@ public class AnnotationSourceProcessor implements SourceProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the class w/ the specified name to the jandex index.
|
||||
*
|
||||
* @param indexer The jandex indexer
|
||||
* @param className the fully qualified class name to be indexed
|
||||
*/
|
||||
private Index parseAndUpdateIndex(List<JaxbRoot<XMLEntityMappings>> mappings, Index annotationIndex) {
|
||||
List<XMLEntityMappings> list = new ArrayList<XMLEntityMappings>( mappings.size() );
|
||||
for ( JaxbRoot<XMLEntityMappings> jaxbRoot : mappings ) {
|
||||
list.add( jaxbRoot.getRoot() );
|
||||
}
|
||||
return new EntityMappingsMocker( list, annotationIndex, metadata.getServiceRegistry() ).mockNewIndex();
|
||||
}
|
||||
|
||||
private void indexClass(Indexer indexer, String className) {
|
||||
InputStream stream = classLoaderService.getValue().locateResourceStream( className );
|
||||
try {
|
||||
|
@ -150,11 +164,9 @@ public class AnnotationSourceProcessor implements SourceProcessor {
|
|||
|
||||
@Override
|
||||
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
|
||||
this
|
||||
);
|
||||
|
||||
// now we process each hierarchy one at the time
|
||||
|
@ -182,8 +194,8 @@ public class AnnotationSourceProcessor implements SourceProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
private Set<ConfiguredClassHierarchy> createEntityHierarchies() {
|
||||
return ConfiguredClassHierarchyBuilder.createEntityHierarchies( index, metadata.getServiceRegistry() );
|
||||
private Set<ConfiguredClassHierarchy<EntityClass>> createEntityHierarchies() {
|
||||
return ConfiguredClassHierarchyBuilder.createEntityHierarchies( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -193,6 +205,87 @@ public class AnnotationSourceProcessor implements SourceProcessor {
|
|||
QueryBinder.bind( metadata, index );
|
||||
FilterDefBinder.bind( metadata, index );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Index getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassInfo getClassInfo(String name) {
|
||||
DotName dotName = DotName.createSimple( name );
|
||||
return index.getClassByName( dotName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolveAllTypes(String className) {
|
||||
// the resolved type for the top level class in the hierarchy
|
||||
Class<?> clazz = classLoaderService.getValue().classForName( className );
|
||||
ResolvedType resolvedType = typeResolver.resolve( clazz );
|
||||
while ( resolvedType != null ) {
|
||||
// todo - check whether there is already something in the map
|
||||
resolvedTypeCache.put( clazz, resolvedType );
|
||||
resolvedType = resolvedType.getParentClass();
|
||||
if ( resolvedType != null ) {
|
||||
clazz = resolvedType.getErasedType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResolvedType getResolvedType(Class<?> clazz) {
|
||||
// todo - error handling
|
||||
return resolvedTypeCache.get( clazz );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResolvedTypeWithMembers resolveMemberTypes(ResolvedType type) {
|
||||
// todo : is there a reason we create this resolver every time?
|
||||
MemberResolver memberResolver = new MemberResolver( typeResolver );
|
||||
return memberResolver.resolve( type, null, null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceRegistry getServiceRegistry() {
|
||||
return getMetadataImplementor().getServiceRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamingStrategy getNamingStrategy() {
|
||||
return metadata.getNamingStrategy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MappingDefaults getMappingDefaults() {
|
||||
return metadata.getMappingDefaults();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataImplementor getMetadataImplementor() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Class<T> locateClassByName(String name) {
|
||||
return classLoaderService.getValue().classForName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGloballyQuotedIdentifiers() {
|
||||
return metadata.isGloballyQuotedIdentifiers();
|
||||
}
|
||||
|
||||
private Map<String,JavaType> nameToJavaTypeMap = new HashMap<String, JavaType>();
|
||||
|
||||
@Override
|
||||
public JavaType makeJavaType(String className) {
|
||||
JavaType javaType = nameToJavaTypeMap.get( className );
|
||||
if ( javaType == null ) {
|
||||
javaType = new JavaType( locateClassByName( className ) );
|
||||
nameToJavaTypeMap.put( className, javaType );
|
||||
}
|
||||
return javaType;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.util;
|
||||
package org.hibernate.metamodel.binder.source.annotations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -38,9 +38,7 @@ import org.jboss.jandex.DotName;
|
|||
|
||||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.metamodel.source.annotations.AnnotationBindingContext;
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClassHierarchy;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClassHierarchy;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EmbeddableClass;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EntityClass;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
|
@ -61,8 +59,8 @@ public class ConfiguredClassHierarchyBuilder {
|
|||
*
|
||||
* @return a set of {@code ConfiguredClassHierarchy}s. One for each "leaf" entity.
|
||||
*/
|
||||
public static Set<ConfiguredClassHierarchy<EntityClass>> createEntityHierarchies(AnnotationBindingContext context) {
|
||||
ClassLoaderService classLoaderService = context.classLoaderService();
|
||||
public static Set<ConfiguredClassHierarchy<EntityClass>> createEntityHierarchies(AnnotationsBindingContext context) {
|
||||
ClassLoaderService classLoaderService = context.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
Map<ClassInfo, List<ClassInfo>> processedClassInfos = new HashMap<ClassInfo, List<ClassInfo>>();
|
||||
|
||||
for ( ClassInfo info : context.getIndex().getKnownClasses() ) {
|
||||
|
@ -120,7 +118,7 @@ public class ConfiguredClassHierarchyBuilder {
|
|||
*
|
||||
* @return a set of {@code ConfiguredClassHierarchy}s. One for each "leaf" entity.
|
||||
*/
|
||||
public static ConfiguredClassHierarchy<EmbeddableClass> createEmbeddableHierarchy(Class<?> embeddableClass, AccessType accessType, AnnotationBindingContext context) {
|
||||
public static ConfiguredClassHierarchy<EmbeddableClass> createEmbeddableHierarchy(Class<?> embeddableClass, AccessType accessType, AnnotationsBindingContext context) {
|
||||
|
||||
ClassInfo embeddableClassInfo = context.getClassInfo( embeddableClass.getName() );
|
||||
if ( embeddableClassInfo == null ) {
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations;
|
||||
package org.hibernate.metamodel.binder.source.annotations;
|
||||
|
||||
import org.jboss.jandex.DotName;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations;
|
||||
package org.hibernate.metamodel.binder.source.annotations;
|
||||
|
||||
import javax.persistence.Access;
|
||||
import javax.persistence.AccessType;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.util;
|
||||
package org.hibernate.metamodel.binder.source.annotations;
|
||||
|
||||
import java.beans.Introspector;
|
||||
import java.io.IOException;
|
|
@ -1,4 +1,4 @@
|
|||
package org.hibernate.metamodel.source.annotations.util;
|
||||
package org.hibernate.metamodel.binder.source.annotations;
|
||||
|
||||
import java.beans.Introspector;
|
||||
import java.lang.reflect.Field;
|
|
@ -0,0 +1,209 @@
|
|||
/*
|
||||
* 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.source.annotations;
|
||||
|
||||
import javax.persistence.SharedCacheMode;
|
||||
|
||||
import org.jboss.jandex.AnnotationInstance;
|
||||
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.hibernate.annotations.OptimisticLockType;
|
||||
import org.hibernate.annotations.PolymorphismType;
|
||||
import org.hibernate.cache.spi.access.AccessType;
|
||||
import org.hibernate.engine.OptimisticLockStyle;
|
||||
import org.hibernate.metamodel.binder.source.RootEntityDescriptor;
|
||||
import org.hibernate.metamodel.binder.source.TableDescriptor;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClass;
|
||||
import org.hibernate.metamodel.binding.Caching;
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
* @author Gail Badner
|
||||
* @author Hardy Ferentschik
|
||||
*/
|
||||
public class RootEntityDescriptorImpl extends AbstractEntityDescriptorImpl implements RootEntityDescriptor {
|
||||
private final boolean mutable;
|
||||
private final boolean explicitPolymorphism;
|
||||
private final String whereFilter;
|
||||
private final String rowId;
|
||||
private final Caching caching;
|
||||
private final OptimisticLockStyle optimisticLockStyle;
|
||||
|
||||
private final TableDescriptor baseTableDescriptor;
|
||||
|
||||
public RootEntityDescriptorImpl(ConfiguredClass configuredClass, AnnotationsBindingContext bindingContext) {
|
||||
super( configuredClass, null, InheritanceType.NO_INHERITANCE, bindingContext );
|
||||
|
||||
final AnnotationInstance hibernateEntityAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), HibernateDotNames.ENTITY
|
||||
);
|
||||
|
||||
OptimisticLockType optimisticLockType = OptimisticLockType.VERSION;
|
||||
if ( hibernateEntityAnnotation != null && hibernateEntityAnnotation.value( "optimisticLock" ) != null ) {
|
||||
optimisticLockType = OptimisticLockType.valueOf( hibernateEntityAnnotation.value( "optimisticLock" ).asEnum() );
|
||||
}
|
||||
this.optimisticLockStyle = OptimisticLockStyle.valueOf( optimisticLockType.name() );
|
||||
|
||||
final PolymorphismType polymorphism = hibernateEntityAnnotation != null && hibernateEntityAnnotation.value( "polymorphism" ) != null
|
||||
? PolymorphismType.valueOf( hibernateEntityAnnotation.value( "polymorphism" ).asEnum() )
|
||||
: PolymorphismType.IMPLICIT;
|
||||
this.explicitPolymorphism = polymorphism != PolymorphismType.IMPLICIT;
|
||||
|
||||
final AnnotationInstance hibernateImmutableAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), HibernateDotNames.IMMUTABLE
|
||||
);
|
||||
this.mutable = hibernateImmutableAnnotation == null
|
||||
&& hibernateEntityAnnotation != null
|
||||
&& hibernateEntityAnnotation.value( "mutable" ) != null
|
||||
&& hibernateEntityAnnotation.value( "mutable" ).asBoolean();
|
||||
|
||||
final AnnotationInstance whereAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), HibernateDotNames.WHERE
|
||||
);
|
||||
this.whereFilter = whereAnnotation != null && whereAnnotation.value( "clause" ) != null
|
||||
? whereAnnotation.value( "clause" ).asString()
|
||||
: null;
|
||||
|
||||
final AnnotationInstance rowIdAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), HibernateDotNames.ROW_ID
|
||||
);
|
||||
this.rowId = rowIdAnnotation != null && rowIdAnnotation.value() != null
|
||||
? rowIdAnnotation.value().asString()
|
||||
: null;
|
||||
|
||||
this.caching = interpretCaching( configuredClass, bindingContext );
|
||||
|
||||
final AnnotationInstance tableAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), JPADotNames.TABLE
|
||||
);
|
||||
this.baseTableDescriptor = new TableDescriptorImpl(
|
||||
tableAnnotation.value( "schema" ) == null
|
||||
? null
|
||||
: tableAnnotation.value( "schema" ).asString(),
|
||||
tableAnnotation.value( "catalog" ) == null
|
||||
? null
|
||||
: tableAnnotation.value( "catalog" ).asString(),
|
||||
tableAnnotation.value( "name" ) == null
|
||||
? null
|
||||
: tableAnnotation.value( "name" ).asString(),
|
||||
this,
|
||||
bindingContext
|
||||
);
|
||||
}
|
||||
|
||||
private Caching interpretCaching(ConfiguredClass configuredClass, AnnotationsBindingContext bindingContext) {
|
||||
final AnnotationInstance hibernateCacheAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), HibernateDotNames.CACHE
|
||||
);
|
||||
if ( hibernateCacheAnnotation != null ) {
|
||||
final AccessType accessType = hibernateCacheAnnotation.value( "usage" ) == null
|
||||
? bindingContext.getMappingDefaults().getCacheAccessType()
|
||||
: CacheConcurrencyStrategy.parse( hibernateCacheAnnotation.value( "usage" ).asEnum() ).toAccessType();
|
||||
return new Caching(
|
||||
hibernateCacheAnnotation.value( "region" ) == null
|
||||
? configuredClass.getName()
|
||||
: hibernateCacheAnnotation.value( "region" ).asString(),
|
||||
accessType,
|
||||
hibernateCacheAnnotation.value( "include" ) != null
|
||||
&& "all".equals( hibernateCacheAnnotation.value( "include" ).asString() )
|
||||
);
|
||||
}
|
||||
|
||||
final AnnotationInstance jpaCacheableAnnotation = JandexHelper.getSingleAnnotation(
|
||||
configuredClass.getClassInfo(), JPADotNames.CACHEABLE
|
||||
);
|
||||
|
||||
boolean cacheable = true; // true is the default
|
||||
if ( jpaCacheableAnnotation != null && jpaCacheableAnnotation.value() != null ) {
|
||||
cacheable = jpaCacheableAnnotation.value().asBoolean();
|
||||
}
|
||||
|
||||
final boolean doCaching;
|
||||
switch ( bindingContext.getMetadataImplementor().getOptions().getSharedCacheMode() ) {
|
||||
case ALL: {
|
||||
doCaching = true;
|
||||
break;
|
||||
}
|
||||
case ENABLE_SELECTIVE: {
|
||||
doCaching = cacheable;
|
||||
break;
|
||||
}
|
||||
case DISABLE_SELECTIVE: {
|
||||
doCaching = jpaCacheableAnnotation == null || cacheable;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// treat both NONE and UNSPECIFIED the same
|
||||
doCaching = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! doCaching ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Caching(
|
||||
configuredClass.getName(),
|
||||
bindingContext.getMappingDefaults().getCacheAccessType(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMutable() {
|
||||
return mutable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExplicitPolymorphism() {
|
||||
return explicitPolymorphism;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWhereFilter() {
|
||||
return whereFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRowId() {
|
||||
return rowId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Caching getCaching() {
|
||||
return caching;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OptimisticLockStyle getOptimisticLockStyle() {
|
||||
return optimisticLockStyle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDescriptor getBaseTable() {
|
||||
return baseTableDescriptor;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* 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.source.annotations;
|
||||
|
||||
import org.hibernate.metamodel.binder.Origin;
|
||||
import org.hibernate.metamodel.binder.source.EntityDescriptor;
|
||||
import org.hibernate.metamodel.binder.source.MetaAttributeContext;
|
||||
import org.hibernate.metamodel.binder.source.TableDescriptor;
|
||||
import org.hibernate.metamodel.binder.source.UnifiedDescriptorObject;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class TableDescriptorImpl implements TableDescriptor {
|
||||
private final String explicitSchemaName;
|
||||
private final String explicitCatalogName;
|
||||
private final String tableName;
|
||||
|
||||
private final EntityDescriptor entityDescriptor;
|
||||
private final AnnotationsBindingContext bindingContext;
|
||||
|
||||
public TableDescriptorImpl(
|
||||
String explicitSchemaName,
|
||||
String explicitCatalogName,
|
||||
String tableName,
|
||||
EntityDescriptor entityDescriptor, AnnotationsBindingContext bindingContext) {
|
||||
this.explicitSchemaName = explicitSchemaName;
|
||||
this.explicitCatalogName = explicitCatalogName;
|
||||
this.tableName = tableName;
|
||||
this.entityDescriptor = entityDescriptor;
|
||||
this.bindingContext = bindingContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExplicitSchemaName() {
|
||||
return explicitSchemaName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExplicitCatalogName() {
|
||||
return explicitCatalogName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Origin getOrigin() {
|
||||
// return bindingContext.getOrigin();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnifiedDescriptorObject getContainingDescriptor() {
|
||||
return entityDescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaAttributeContext getMetaAttributeContext() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -21,8 +21,9 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.entity;
|
||||
package org.hibernate.metamodel.binder.source.annotations.entity;
|
||||
|
||||
import javax.persistence.AccessType;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Method;
|
||||
|
@ -36,7 +37,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import javax.persistence.AccessType;
|
||||
|
||||
import com.fasterxml.classmate.ResolvedTypeWithMembers;
|
||||
import com.fasterxml.classmate.members.HierarchicType;
|
||||
|
@ -52,17 +52,17 @@ import org.jboss.logging.Logger;
|
|||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.metamodel.source.annotations.AnnotationBindingContext;
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.AnnotationsBindingContext;
|
||||
import org.hibernate.metamodel.binder.source.annotations.ConfiguredClassHierarchyBuilder;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.ReflectionHelper;
|
||||
import org.hibernate.metamodel.source.annotations.attribute.AssociationAttribute;
|
||||
import org.hibernate.metamodel.source.annotations.attribute.AttributeOverride;
|
||||
import org.hibernate.metamodel.source.annotations.attribute.AttributeType;
|
||||
import org.hibernate.metamodel.source.annotations.attribute.MappedAttribute;
|
||||
import org.hibernate.metamodel.source.annotations.attribute.SimpleAttribute;
|
||||
import org.hibernate.metamodel.source.annotations.util.ConfiguredClassHierarchyBuilder;
|
||||
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.metamodel.source.annotations.util.ReflectionHelper;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EmbeddableClass;
|
||||
|
||||
/**
|
||||
* Base class for a configured entity, mapped super class or embeddable
|
||||
|
@ -70,11 +70,7 @@ import org.hibernate.metamodel.source.annotations.util.ReflectionHelper;
|
|||
* @author Hardy Ferentschik
|
||||
*/
|
||||
public class ConfiguredClass {
|
||||
|
||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
|
||||
CoreMessageLogger.class,
|
||||
ConfiguredClass.class.getName()
|
||||
);
|
||||
public static final Logger LOG = Logger.getLogger( ConfiguredClass.class.getName() );
|
||||
|
||||
/**
|
||||
* The parent of this configured class or {@code null} in case this configured class is the root of a hierarchy.
|
||||
|
@ -130,16 +126,17 @@ public class ConfiguredClass {
|
|||
private final Set<String> transientFieldNames = new HashSet<String>();
|
||||
private final Set<String> transientMethodNames = new HashSet<String>();
|
||||
|
||||
private final AnnotationBindingContext context;
|
||||
private final AnnotationsBindingContext context;
|
||||
|
||||
public ConfiguredClass(ClassInfo classInfo,
|
||||
AccessType defaultAccessType,
|
||||
ConfiguredClass parent,
|
||||
AnnotationBindingContext context) {
|
||||
public ConfiguredClass(
|
||||
ClassInfo classInfo,
|
||||
AccessType defaultAccessType,
|
||||
ConfiguredClass parent,
|
||||
AnnotationsBindingContext context) {
|
||||
this.parent = parent;
|
||||
this.context = context;
|
||||
this.classInfo = classInfo;
|
||||
this.clazz = context.classLoaderService().classForName( classInfo.toString() );
|
||||
this.clazz = context.locateClassByName( classInfo.toString() );
|
||||
this.configuredClassType = determineType();
|
||||
this.classAccessType = determineClassAccessType( defaultAccessType );
|
||||
this.simpleAttributeMap = new TreeMap<String, SimpleAttribute>();
|
||||
|
@ -477,7 +474,7 @@ public class ConfiguredClass {
|
|||
|
||||
context.resolveAllTypes( type.getName() );
|
||||
ConfiguredClassHierarchy<EmbeddableClass> hierarchy = ConfiguredClassHierarchyBuilder.createEmbeddableHierarchy(
|
||||
context.loadClass( embeddableClassInfo.toString() ),
|
||||
context.<Object>locateClassByName( embeddableClassInfo.toString() ),
|
||||
classAccessType,
|
||||
context
|
||||
);
|
|
@ -21,12 +21,12 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.entity;
|
||||
package org.hibernate.metamodel.binder.source.annotations.entity;
|
||||
|
||||
import javax.persistence.AccessType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import javax.persistence.AccessType;
|
||||
|
||||
import org.jboss.jandex.AnnotationInstance;
|
||||
import org.jboss.jandex.ClassInfo;
|
||||
|
@ -34,10 +34,12 @@ import org.jboss.jandex.FieldInfo;
|
|||
import org.jboss.jandex.MethodInfo;
|
||||
|
||||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.metamodel.binder.source.annotations.AnnotationsBindingContext;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
import org.hibernate.metamodel.source.annotations.AnnotationBindingContext;
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EmbeddableClass;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EntityClass;
|
||||
|
||||
/**
|
||||
* Contains information about the access and inheritance type for all classes within a class hierarchy.
|
||||
|
@ -49,7 +51,7 @@ public class ConfiguredClassHierarchy<T extends ConfiguredClass> implements Iter
|
|||
private final InheritanceType inheritanceType;
|
||||
private final List<T> configuredClasses;
|
||||
|
||||
public static ConfiguredClassHierarchy<EntityClass> createEntityClassHierarchy(List<ClassInfo> classInfoList, AnnotationBindingContext context) {
|
||||
public static ConfiguredClassHierarchy<EntityClass> createEntityClassHierarchy(List<ClassInfo> classInfoList, AnnotationsBindingContext context) {
|
||||
AccessType defaultAccessType = determineDefaultAccessType( classInfoList );
|
||||
InheritanceType inheritanceType = determineInheritanceType( classInfoList );
|
||||
return new ConfiguredClassHierarchy<EntityClass>(
|
||||
|
@ -61,7 +63,10 @@ public class ConfiguredClassHierarchy<T extends ConfiguredClass> implements Iter
|
|||
);
|
||||
}
|
||||
|
||||
public static ConfiguredClassHierarchy<EmbeddableClass> createEmbeddableClassHierarchy(List<ClassInfo> classes, AccessType accessType, AnnotationBindingContext context) {
|
||||
public static ConfiguredClassHierarchy<EmbeddableClass> createEmbeddableClassHierarchy(
|
||||
List<ClassInfo> classes,
|
||||
AccessType accessType,
|
||||
AnnotationsBindingContext context) {
|
||||
return new ConfiguredClassHierarchy<EmbeddableClass>(
|
||||
classes,
|
||||
context,
|
||||
|
@ -71,7 +76,12 @@ public class ConfiguredClassHierarchy<T extends ConfiguredClass> implements Iter
|
|||
);
|
||||
}
|
||||
|
||||
private ConfiguredClassHierarchy(List<ClassInfo> classInfoList, AnnotationBindingContext context, AccessType defaultAccessType, InheritanceType inheritanceType, Class<T> configuredClassType) {
|
||||
private ConfiguredClassHierarchy(
|
||||
List<ClassInfo> classInfoList,
|
||||
AnnotationsBindingContext context,
|
||||
AccessType defaultAccessType,
|
||||
InheritanceType inheritanceType,
|
||||
Class<T> configuredClassType) {
|
||||
this.defaultAccessType = defaultAccessType;
|
||||
this.inheritanceType = inheritanceType;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.entity;
|
||||
package org.hibernate.metamodel.binder.source.annotations.entity;
|
||||
|
||||
/**
|
||||
* @author Hardy Ferentschik
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.entity;
|
||||
package org.hibernate.metamodel.binder.source.annotations.entity;
|
||||
|
||||
import javax.persistence.GenerationType;
|
||||
import java.util.HashMap;
|
||||
|
@ -46,6 +46,11 @@ import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
|
|||
import org.hibernate.id.IdentifierGenerator;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.metamodel.binder.source.MetadataImplementor;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.state.binding.AbstractEntityDescriptorImpl;
|
||||
import org.hibernate.metamodel.binder.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.global.IdGeneratorBinder;
|
||||
import org.hibernate.metamodel.binding.Caching;
|
||||
import org.hibernate.metamodel.binding.CustomSQL;
|
||||
import org.hibernate.metamodel.binding.EntityBinding;
|
||||
|
@ -65,8 +70,6 @@ import org.hibernate.metamodel.relational.Schema;
|
|||
import org.hibernate.metamodel.relational.Table;
|
||||
import org.hibernate.metamodel.relational.TableSpecification;
|
||||
import org.hibernate.metamodel.relational.UniqueKey;
|
||||
import org.hibernate.metamodel.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.source.annotations.attribute.AssociationAttribute;
|
||||
import org.hibernate.metamodel.source.annotations.attribute.AttributeOverride;
|
||||
import org.hibernate.metamodel.source.annotations.attribute.MappedAttribute;
|
||||
|
@ -77,9 +80,8 @@ 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.AbstractEntityDescriptorImpl;
|
||||
import org.hibernate.metamodel.source.annotations.global.IdGeneratorBinder;
|
||||
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EmbeddableClass;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EntityClass;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
||||
/**
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.entity;
|
||||
package org.hibernate.metamodel.binder.source.annotations.entity;
|
||||
|
||||
/**
|
||||
* An emum for the type of id configuration for an entity.
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.entity.state.binding;
|
||||
package org.hibernate.metamodel.binder.source.annotations.entity.state.binding;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
|
@ -21,16 +21,16 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.entity.state.binding;
|
||||
package org.hibernate.metamodel.binder.source.annotations.entity.state.binding;
|
||||
|
||||
import org.hibernate.annotations.OptimisticLockType;
|
||||
import org.hibernate.engine.OptimisticLockStyle;
|
||||
import org.hibernate.metamodel.binder.source.BindingContext;
|
||||
import org.hibernate.metamodel.binder.source.RootEntityDescriptor;
|
||||
import org.hibernate.metamodel.binder.source.TableDescriptor;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClass;
|
||||
import org.hibernate.metamodel.binding.Caching;
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClass;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.global;
|
||||
package org.hibernate.metamodel.binder.source.annotations.global;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -33,10 +33,10 @@ import org.hibernate.MappingException;
|
|||
import org.hibernate.annotations.FetchMode;
|
||||
import org.hibernate.annotations.FetchProfiles;
|
||||
import org.hibernate.metamodel.binder.source.MetadataImplementor;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
import org.hibernate.metamodel.binding.FetchProfile;
|
||||
import org.hibernate.metamodel.binding.FetchProfile.Fetch;
|
||||
import org.hibernate.metamodel.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.HibernateDotNames;
|
||||
|
||||
/**
|
||||
* Binds fetch profiles found in annotations.
|
||||
|
@ -81,8 +81,8 @@ public class FetchProfileBinder {
|
|||
if ( !fetchMode.equals( org.hibernate.annotations.FetchMode.JOIN ) ) {
|
||||
throw new MappingException( "Only FetchMode.JOIN is currently supported" );
|
||||
}
|
||||
String entityName = JandexHelper.getValue( override, "entity", String.class );
|
||||
String associationName = JandexHelper.getValue( override, "association", String.class );
|
||||
final String entityName = JandexHelper.getValue( override, "entity", String.class );
|
||||
final String associationName = JandexHelper.getValue( override, "association", String.class );
|
||||
fetches.add( new Fetch( entityName, associationName, fetchMode.toString().toLowerCase() ) );
|
||||
}
|
||||
metadata.addFetchProfile( new FetchProfile( name, fetches ) );
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.global;
|
||||
package org.hibernate.metamodel.binder.source.annotations.global;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -35,8 +35,8 @@ import org.hibernate.annotations.FilterDefs;
|
|||
import org.hibernate.engine.spi.FilterDefinition;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.metamodel.binder.source.MetadataImplementor;
|
||||
import org.hibernate.metamodel.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
public class FilterDefBinder {
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.global;
|
||||
package org.hibernate.metamodel.binder.source.annotations.global;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -45,10 +45,10 @@ import org.hibernate.id.enhanced.TableGenerator;
|
|||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.metamodel.binder.source.MetadataImplementor;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
import org.hibernate.metamodel.binding.IdGenerator;
|
||||
import org.hibernate.metamodel.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
|
||||
public class IdGeneratorBinder {
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.global;
|
||||
package org.hibernate.metamodel.binder.source.annotations.global;
|
||||
|
||||
import java.util.HashMap;
|
||||
import javax.persistence.NamedNativeQueries;
|
||||
|
@ -46,9 +46,9 @@ import org.hibernate.engine.spi.NamedSQLQueryDefinition;
|
|||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.metamodel.binder.source.MetadataImplementor;
|
||||
import org.hibernate.metamodel.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
|
||||
public class QueryBinder {
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.global;
|
||||
package org.hibernate.metamodel.binder.source.annotations.global;
|
||||
|
||||
import org.jboss.jandex.AnnotationInstance;
|
||||
import org.jboss.jandex.Index;
|
||||
|
@ -31,13 +31,13 @@ import org.hibernate.AnnotationException;
|
|||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.metamodel.binder.source.MetadataImplementor;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
import org.hibernate.metamodel.relational.Column;
|
||||
import org.hibernate.metamodel.relational.ObjectName;
|
||||
import org.hibernate.metamodel.relational.Schema;
|
||||
import org.hibernate.metamodel.relational.SimpleValue;
|
||||
import org.hibernate.metamodel.relational.Table;
|
||||
import org.hibernate.metamodel.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.HibernateDotNames;
|
||||
|
||||
/**
|
||||
* Binds table related information. This binder is called after the entities are bound.
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.global;
|
||||
package org.hibernate.metamodel.binder.source.annotations.global;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -35,9 +35,9 @@ import org.hibernate.annotations.TypeDefs;
|
|||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.metamodel.binder.source.MetadataImplementor;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
import org.hibernate.metamodel.binding.TypeDef;
|
||||
import org.hibernate.metamodel.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.HibernateDotNames;
|
||||
|
||||
public class TypeDefBinder {
|
||||
|
|
@ -21,8 +21,10 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml;
|
||||
package org.hibernate.metamodel.binder.source.annotations;
|
||||
|
||||
/**
|
||||
* Classes related to parsing orm.xml
|
||||
* This code in this package is responsible for performing the process of preparing metadata from annotations
|
||||
* and {@code orm.xml} into the forms needed by {@link org.hibernate.metamodel.binder.EntityBinder}. The main driver
|
||||
* of this process is the {@link AnnotationsSourceProcessor} class.
|
||||
*/
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml;
|
||||
|
||||
import org.jboss.jandex.DotName;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.filter;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.filter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
@ -32,7 +32,7 @@ import java.util.Set;
|
|||
import org.jboss.jandex.AnnotationInstance;
|
||||
import org.jboss.jandex.DotName;
|
||||
|
||||
import org.hibernate.metamodel.source.annotations.xml.mocker.IndexBuilder;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.IndexBuilder;
|
||||
|
||||
/**
|
||||
* @author Strong Liu
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.filter;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.filter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -35,7 +35,7 @@ import org.jboss.jandex.AnnotationInstance;
|
|||
import org.jboss.jandex.AnnotationTarget;
|
||||
import org.jboss.jandex.DotName;
|
||||
|
||||
import org.hibernate.metamodel.source.annotations.xml.mocker.MockHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.MockHelper;
|
||||
|
||||
/**
|
||||
* @author Strong Liu
|
|
@ -21,13 +21,13 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.filter;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.filter;
|
||||
|
||||
import org.jboss.jandex.AnnotationInstance;
|
||||
import org.jboss.jandex.DotName;
|
||||
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.source.annotations.xml.mocker.IndexBuilder;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.IndexBuilder;
|
||||
|
||||
/**
|
||||
* @author Strong Liu
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.filter;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.filter;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.filter;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.filter;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -30,7 +30,7 @@ import org.jboss.jandex.AnnotationInstance;
|
|||
import org.jboss.jandex.AnnotationTarget;
|
||||
import org.jboss.jandex.DotName;
|
||||
|
||||
import org.hibernate.metamodel.source.annotations.xml.mocker.MockHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.MockHelper;
|
||||
|
||||
/**
|
||||
* @author Strong Liu
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import org.jboss.jandex.AnnotationInstance;
|
||||
import org.jboss.jandex.AnnotationTarget;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -33,7 +33,7 @@ import org.jboss.jandex.DotName;
|
|||
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLAccessType;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLUniqueConstraint;
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
|
||||
/**
|
||||
* Base class for the mock jandex annotations created from orm.xml.
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -36,10 +36,10 @@ import org.jboss.logging.Logger;
|
|||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.PseudoJpaDotNames;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLAccessType;
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.metamodel.source.annotations.xml.PseudoJpaDotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
|
||||
/**
|
||||
* @author Strong Liu
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -34,13 +34,13 @@ import org.jboss.logging.Logger;
|
|||
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.filter.IndexedAnnotationFilter;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLEmbeddable;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLEntity;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLMappedSuperclass;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLTable;
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.metamodel.source.annotations.xml.filter.IndexedAnnotationFilter;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
|
||||
/**
|
||||
* @author Strong Liu
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import org.jboss.jandex.ClassInfo;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import org.jboss.jandex.ClassInfo;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -47,7 +47,7 @@ import org.hibernate.metamodel.source.annotation.xml.XMLNamedQuery;
|
|||
import org.hibernate.metamodel.source.annotation.xml.XMLSequenceGenerator;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLSqlResultSetMapping;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLTableGenerator;
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
|
||||
/**
|
||||
* @author Strong Liu
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -38,7 +38,7 @@ import org.jboss.logging.Logger;
|
|||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.metamodel.source.annotations.xml.filter.IndexedAnnotationFilter;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.filter.IndexedAnnotationFilter;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.beans.Introspector;
|
||||
import java.lang.reflect.Field;
|
||||
|
@ -42,7 +42,7 @@ import org.jboss.jandex.Type;
|
|||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLCascadeType;
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -9,8 +9,8 @@ import org.jboss.jandex.AnnotationValue;
|
|||
import org.jboss.jandex.ClassInfo;
|
||||
import org.jboss.jandex.DotName;
|
||||
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.PseudoJpaDotNames;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLPersistenceUnitDefaults;
|
||||
import org.hibernate.metamodel.source.annotations.xml.PseudoJpaDotNames;
|
||||
|
||||
/**
|
||||
* @author Strong Liu
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLCollectionTable;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLJoinTable;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import org.jboss.jandex.ClassInfo;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import org.jboss.jandex.ClassInfo;
|
||||
|
|
@ -27,6 +27,7 @@ import java.util.List;
|
|||
|
||||
import org.hibernate.metamodel.binder.Origin;
|
||||
import org.hibernate.metamodel.binder.source.BindingContext;
|
||||
import org.hibernate.metamodel.binder.source.MetaAttributeContext;
|
||||
import org.hibernate.metamodel.binder.source.hbm.xml.mapping.EntityElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLFetchProfileElement;
|
||||
|
||||
|
@ -38,6 +39,8 @@ import org.hibernate.metamodel.source.hbm.xml.mapping.XMLFetchProfileElement;
|
|||
public interface HbmBindingContext extends BindingContext {
|
||||
public boolean isAutoImport();
|
||||
|
||||
public MetaAttributeContext getMetaAttributeContext();
|
||||
|
||||
public Origin getOrigin();
|
||||
|
||||
public String determineEntityName(EntityElement entityElement);
|
||||
|
|
|
@ -36,8 +36,8 @@ import org.hibernate.metamodel.binder.source.MetaAttributeContext;
|
|||
import org.hibernate.metamodel.binder.source.hbm.xml.mapping.EntityElement;
|
||||
import org.hibernate.metamodel.binding.CustomSQL;
|
||||
import org.hibernate.metamodel.binding.MetaAttribute;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLClass;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLMetaElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLHibernateMapping;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLMetaElement;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
@ -95,7 +95,7 @@ public class HbmHelper {
|
|||
return extractedMetas;
|
||||
}
|
||||
|
||||
public static String extractEntityName(XMLClass entityClazz, String unqualifiedPackageName) {
|
||||
public static String extractEntityName(XMLHibernateMapping.XMLClass entityClazz, String unqualifiedPackageName) {
|
||||
return extractEntityName( entityClazz.getEntityName(), entityClazz.getName(), unqualifiedPackageName );
|
||||
}
|
||||
|
||||
|
|
|
@ -31,20 +31,25 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.metamodel.MetadataSources;
|
||||
import org.hibernate.metamodel.binder.source.BindingContext;
|
||||
import org.hibernate.metamodel.binder.source.MappingDefaults;
|
||||
import org.hibernate.metamodel.binder.source.MetadataImplementor;
|
||||
import org.hibernate.metamodel.binder.source.SourceProcessor;
|
||||
import org.hibernate.metamodel.binder.source.hbm.xml.mapping.EntityElement;
|
||||
import org.hibernate.metamodel.binder.source.hbm.xml.mapping.SubclassEntityElement;
|
||||
import org.hibernate.metamodel.binder.source.internal.JaxbRoot;
|
||||
import org.hibernate.metamodel.domain.JavaType;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* The {@link SourceProcessor} implementation responsible for processing {@code hbm.xml} sources.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class HbmSourceProcessorImpl implements SourceProcessor {
|
||||
public class HbmSourceProcessorImpl implements SourceProcessor, BindingContext {
|
||||
private final MetadataImplementor metadata;
|
||||
private List<HibernateMappingProcessor> processors;
|
||||
|
||||
|
@ -58,7 +63,7 @@ public class HbmSourceProcessorImpl implements SourceProcessor {
|
|||
this.processors = new ArrayList<HibernateMappingProcessor>();
|
||||
for ( JaxbRoot jaxbRoot : sources.getJaxbRootList() ) {
|
||||
if ( jaxbRoot.getRoot() instanceof XMLHibernateMapping ) {
|
||||
processors.add( new HibernateMappingProcessor( metadata, (JaxbRoot<XMLHibernateMapping>) jaxbRoot ) );
|
||||
processors.add( new HibernateMappingProcessor( this, (JaxbRoot<XMLHibernateMapping>) jaxbRoot ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,4 +180,34 @@ public class HbmSourceProcessorImpl implements SourceProcessor {
|
|||
processor.processMappingDependentMetadata();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceRegistry getServiceRegistry() {
|
||||
return metadata.getServiceRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamingStrategy getNamingStrategy() {
|
||||
return metadata.getNamingStrategy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MappingDefaults getMappingDefaults() {
|
||||
return metadata.getMappingDefaults();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataImplementor getMetadataImplementor() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Class<T> locateClassByName(String name) {
|
||||
return metadata.locateClassByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaType makeJavaType(String className) {
|
||||
return metadata.makeJavaType( className );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,14 +49,14 @@ import org.hibernate.metamodel.binding.TypeDef;
|
|||
import org.hibernate.metamodel.domain.JavaType;
|
||||
import org.hibernate.metamodel.relational.AuxiliaryDatabaseObject;
|
||||
import org.hibernate.metamodel.relational.BasicAuxiliaryDatabaseObjectImpl;
|
||||
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;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLParamElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLQueryElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlQueryElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSubclassElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLUnionSubclassElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLFetchProfileElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLHibernateMapping;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLJoinedSubclassElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLParamElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLQueryElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLSqlQueryElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLSubclassElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLUnionSubclassElement;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.service.classloading.spi.ClassLoadingException;
|
||||
|
@ -70,7 +70,7 @@ import org.hibernate.type.Type;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class HibernateMappingProcessor implements HbmBindingContext {
|
||||
private final MetadataImplementor metadata;
|
||||
private final HbmSourceProcessorImpl hbmHandler;
|
||||
private final JaxbRoot<XMLHibernateMapping> jaxbRoot;
|
||||
|
||||
private final XMLHibernateMapping hibernateMapping;
|
||||
|
@ -83,13 +83,13 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
|
||||
private final boolean autoImport;
|
||||
|
||||
public HibernateMappingProcessor(MetadataImplementor metadata, JaxbRoot<XMLHibernateMapping> jaxbRoot) {
|
||||
this.metadata = metadata;
|
||||
public HibernateMappingProcessor(HbmSourceProcessorImpl hbmHandler, JaxbRoot<XMLHibernateMapping> jaxbRoot) {
|
||||
this.hbmHandler = hbmHandler;
|
||||
this.jaxbRoot = jaxbRoot;
|
||||
|
||||
this.hibernateMapping = jaxbRoot.getRoot();
|
||||
this.mappingDefaults = new OverriddenMappingDefaults(
|
||||
metadata.getMappingDefaults(),
|
||||
hbmHandler.getMappingDefaults(),
|
||||
hibernateMapping.getPackage(),
|
||||
hibernateMapping.getSchema(),
|
||||
hibernateMapping.getCatalog(),
|
||||
|
@ -102,15 +102,15 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
|
||||
this.autoImport = hibernateMapping.isAutoImport();
|
||||
|
||||
this.entityBinder = new EntityBinder( metadata );
|
||||
this.entityBinder = new EntityBinder( this );
|
||||
|
||||
this.metaAttributeContext = extractMetaAttributes();
|
||||
}
|
||||
|
||||
private MetaAttributeContext extractMetaAttributes() {
|
||||
return hibernateMapping.getMeta() == null
|
||||
? new MetaAttributeContext( metadata.getMetaAttributeContext() )
|
||||
: HbmHelper.extractMetaAttributeContext( hibernateMapping.getMeta(), true, metadata.getMetaAttributeContext() );
|
||||
? new MetaAttributeContext( hbmHandler.getMetadataImplementor().getGlobalMetaAttributeContext() )
|
||||
: HbmHelper.extractMetaAttributeContext( hibernateMapping.getMeta(), true, hbmHandler.getMetadataImplementor().getGlobalMetaAttributeContext() );
|
||||
}
|
||||
|
||||
XMLHibernateMapping getHibernateMapping() {
|
||||
|
@ -129,17 +129,17 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
|
||||
@Override
|
||||
public ServiceRegistry getServiceRegistry() {
|
||||
return metadata.getServiceRegistry();
|
||||
return getMetadataImplementor().getServiceRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamingStrategy getNamingStrategy() {
|
||||
return metadata.getOptions().getNamingStrategy();
|
||||
return getMetadataImplementor().getOptions().getNamingStrategy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGloballyQuotedIdentifiers() {
|
||||
return metadata.isGloballyQuotedIdentifiers();
|
||||
return getMetadataImplementor().isGloballyQuotedIdentifiers();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -154,17 +154,17 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
|
||||
@Override
|
||||
public MetadataImplementor getMetadataImplementor() {
|
||||
return metadata;
|
||||
return hbmHandler.getMetadataImplementor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Class<T> locateClassByName(String name) {
|
||||
return metadata.locateClassByName( name );
|
||||
return getMetadataImplementor().locateClassByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaType makeJavaType(String className) {
|
||||
return metadata.makeJavaType( className );
|
||||
return getMetadataImplementor().makeJavaType( className );
|
||||
}
|
||||
|
||||
public void processIndependentMetadata() {
|
||||
|
@ -206,7 +206,7 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
dialectScopes
|
||||
);
|
||||
}
|
||||
metadata.getDatabase().addAuxiliaryDatabaseObject( auxiliaryDatabaseObject );
|
||||
getMetadataImplementor().addAuxiliaryDatabaseObject( auxiliaryDatabaseObject );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,13 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
for ( XMLParamElement paramElement : typedef.getParam() ) {
|
||||
parameters.put( paramElement.getName(), paramElement.getValue() );
|
||||
}
|
||||
metadata.addTypeDefinition( new TypeDef( typedef.getName(), typedef.getClazz(), parameters ) );
|
||||
getMetadataImplementor().addTypeDefinition(
|
||||
new TypeDef(
|
||||
typedef.getName(),
|
||||
typedef.getClazz(),
|
||||
parameters
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,7 +255,7 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
// todo : should really delay this resolution until later to allow typedef names
|
||||
parameters.put(
|
||||
paramElement.getName(),
|
||||
metadata.getTypeResolver().heuristicType( paramElement.getType() )
|
||||
getMetadataImplementor().getTypeResolver().heuristicType( paramElement.getType() )
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
@ -259,7 +265,7 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
if ( condition == null ) {
|
||||
condition = filterDefinition.getCondition();
|
||||
}
|
||||
metadata.addFilterDefinition( new FilterDefinition( name, condition, parameters ) );
|
||||
getMetadataImplementor().addFilterDefinition( new FilterDefinition( name, condition, parameters ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,7 +274,7 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
return;
|
||||
}
|
||||
for ( XMLHibernateMapping.XMLIdentifierGenerator identifierGeneratorElement : hibernateMapping.getIdentifierGenerator() ) {
|
||||
metadata.registerIdentifierGenerator(
|
||||
getMetadataImplementor().registerIdentifierGenerator(
|
||||
identifierGeneratorElement.getName(),
|
||||
identifierGeneratorElement.getClazz()
|
||||
);
|
||||
|
@ -314,7 +320,7 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
}
|
||||
|
||||
final EntityBinding entityBinding = entityBinder.createEntityBinding( entityDescriptor );
|
||||
metadata.addEntity( entityBinding );
|
||||
getMetadataImplementor().addEntity( entityBinding );
|
||||
processedEntityNames.add( entityBinding.getEntity().getName() );
|
||||
}
|
||||
}
|
||||
|
@ -348,7 +354,7 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
}
|
||||
fetches.add( new FetchProfile.Fetch( entityName, fetch.getAssociation(), fetch.getStyle() ) );
|
||||
}
|
||||
metadata.addFetchProfile( new FetchProfile( profileName, fetches ) );
|
||||
getMetadataImplementor().addFetchProfile( new FetchProfile( profileName, fetches ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -360,7 +366,7 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
String className = getClassName( importValue.getClazz() );
|
||||
String rename = importValue.getRename();
|
||||
rename = ( rename == null ) ? StringHelper.unqualify( className ) : rename;
|
||||
metadata.addImport( className, rename );
|
||||
getMetadataImplementor().addImport( className, rename );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -395,7 +401,7 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
new Value.DeferredInitializer<ClassLoaderService>() {
|
||||
@Override
|
||||
public ClassLoaderService initialize() {
|
||||
return metadata.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
return getMetadataImplementor().getServiceRegistry().getService( ClassLoaderService.class );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* 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.source.hbm.xml.mapping;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface Discriminated {
|
||||
|
||||
}
|
|
@ -34,6 +34,8 @@ import org.jboss.logging.Logger;
|
|||
import org.hibernate.DuplicateMappingException;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cache.spi.RegionFactory;
|
||||
import org.hibernate.cache.spi.access.AccessType;
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.engine.ResultSetMappingDefinition;
|
||||
import org.hibernate.engine.spi.FilterDefinition;
|
||||
|
@ -59,7 +61,7 @@ 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.AnnotationSourceProcessor;
|
||||
import org.hibernate.metamodel.binder.source.annotations.AnnotationsSourceProcessor;
|
||||
import org.hibernate.persister.spi.PersisterClassResolver;
|
||||
import org.hibernate.service.BasicServiceRegistry;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
|
@ -123,12 +125,12 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
if ( options.getSourceProcessingOrder() == SourceProcessingOrder.HBM_FIRST ) {
|
||||
sourceProcessors = new SourceProcessor[] {
|
||||
new HbmSourceProcessorImpl( this ),
|
||||
new AnnotationSourceProcessor( this )
|
||||
new AnnotationsSourceProcessor( this )
|
||||
};
|
||||
}
|
||||
else {
|
||||
sourceProcessors = new SourceProcessor[] {
|
||||
new AnnotationSourceProcessor( this ),
|
||||
new AnnotationsSourceProcessor( this ),
|
||||
new HbmSourceProcessorImpl( this )
|
||||
};
|
||||
}
|
||||
|
@ -459,7 +461,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
private final MetaAttributeContext globalMetaAttributeContext = new MetaAttributeContext();
|
||||
|
||||
@Override
|
||||
public MetaAttributeContext getMetaAttributeContext() {
|
||||
public MetaAttributeContext getGlobalMetaAttributeContext() {
|
||||
return globalMetaAttributeContext;
|
||||
}
|
||||
|
||||
|
@ -556,5 +558,22 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
public boolean areAssociationsLazy() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private final Value<AccessType> regionFactorySpecifiedDefaultAccessType = new Value<AccessType>(
|
||||
new Value.DeferredInitializer<AccessType>() {
|
||||
@Override
|
||||
public AccessType initialize() {
|
||||
final RegionFactory regionFactory = getServiceRegistry().getService( RegionFactory.class );
|
||||
return regionFactory.getDefaultAccessType();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@Override
|
||||
public AccessType getCacheAccessType() {
|
||||
return options.getDefaultAccessType() != null
|
||||
? options.getDefaultAccessType()
|
||||
: regionFactorySpecifiedDefaultAccessType.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.binder.source.internal;
|
||||
|
||||
import org.hibernate.cache.spi.access.AccessType;
|
||||
import org.hibernate.metamodel.binder.source.MappingDefaults;
|
||||
|
||||
/**
|
||||
|
@ -105,4 +106,9 @@ public class OverriddenMappingDefaults implements MappingDefaults {
|
|||
public boolean areAssociationsLazy() {
|
||||
return associationLaziness == null ? overriddenValues.areAssociationsLazy() : associationLaziness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessType getCacheAccessType() {
|
||||
return overriddenValues.getCacheAccessType();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ import org.jboss.jandex.AnnotationValue;
|
|||
import org.jboss.jandex.DotName;
|
||||
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.hibernate.metamodel.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
|
||||
/**
|
||||
* @author Hardy Ferentschik
|
||||
|
|
|
@ -27,17 +27,19 @@ import javax.persistence.AccessType;
|
|||
|
||||
import org.jboss.jandex.ClassInfo;
|
||||
|
||||
import org.hibernate.metamodel.source.annotations.AnnotationBindingContext;
|
||||
import org.hibernate.metamodel.binder.source.annotations.AnnotationsBindingContext;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClass;
|
||||
|
||||
/**
|
||||
* @author Hardy Ferentschik
|
||||
*/
|
||||
public class EmbeddableClass extends ConfiguredClass {
|
||||
// todo - need to take care of the attribute path (HF)
|
||||
public EmbeddableClass(ClassInfo classInfo,
|
||||
EmbeddableClass parent,
|
||||
AccessType defaultAccessType,
|
||||
AnnotationBindingContext context) {
|
||||
public EmbeddableClass(
|
||||
ClassInfo classInfo,
|
||||
EmbeddableClass parent,
|
||||
AccessType defaultAccessType,
|
||||
AnnotationsBindingContext context) {
|
||||
super( classInfo, defaultAccessType, parent, context );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,9 +33,12 @@ import org.jboss.jandex.DotName;
|
|||
|
||||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.metamodel.binder.source.annotations.AnnotationsBindingContext;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClass;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClassType;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.IdType;
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
import org.hibernate.metamodel.source.annotations.AnnotationBindingContext;
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
|
||||
/**
|
||||
* Represents an entity or mapped superclass configured via annotations/xml.
|
||||
|
@ -50,12 +53,12 @@ public class EntityClass extends ConfiguredClass {
|
|||
private final IdType idType;
|
||||
private final EntityClass jpaEntityParent;
|
||||
|
||||
public EntityClass(ClassInfo classInfo,
|
||||
EntityClass parent,
|
||||
AccessType hierarchyAccessType,
|
||||
InheritanceType inheritanceType,
|
||||
AnnotationBindingContext context) {
|
||||
|
||||
public EntityClass(
|
||||
ClassInfo classInfo,
|
||||
EntityClass parent,
|
||||
AccessType hierarchyAccessType,
|
||||
InheritanceType inheritanceType,
|
||||
AnnotationsBindingContext context) {
|
||||
super( classInfo, hierarchyAccessType, parent, context );
|
||||
this.hierarchyAccessType = hierarchyAccessType;
|
||||
this.inheritanceType = inheritanceType;
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* 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.annotations.entity;
|
||||
|
||||
/**
|
||||
* This package contains binding code for entities. In particular it contains classes like {@code ConfiguredClass} and
|
||||
* {@code MappedAttribute} which are populated from annotations to make it easier to bind to the Hibernate metamodel.
|
||||
* The configured classes (entities) are also ordered in a ways that they can be bound in the right order.
|
||||
*/
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* 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.annotations.global;
|
||||
|
||||
/**
|
||||
* This package contains binders for global configuration annotations, for example {@link javax.persistence.SequenceGenerator},
|
||||
* {@link javax.persistence.TableGenerator} or {@link org.hibernate.annotations.FetchProfile}.
|
||||
* This type of annotations contains global configuration which can be bound w/o information of the mapped entities.
|
||||
*/
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* 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.annotations;
|
||||
|
||||
/**
|
||||
* This package and its sub-packages contains the binding code for binding annotation based configuration to the Hibernate metamodel.
|
||||
*/
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* 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.annotations.util;
|
||||
|
||||
/**
|
||||
* Utility classes for annotation parsing and binding.
|
||||
*/
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* 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.annotations.xml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jboss.jandex.Index;
|
||||
|
||||
import org.hibernate.metamodel.binder.source.MetadataImplementor;
|
||||
import org.hibernate.metamodel.binder.source.internal.JaxbRoot;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLEntityMappings;
|
||||
import org.hibernate.metamodel.source.annotations.xml.mocker.EntityMappingsMocker;
|
||||
|
||||
/**
|
||||
* @author Hardy Ferentschik
|
||||
* @todo Is this still class really still necessary? Maybe it should be removed (HF)
|
||||
*/
|
||||
public class OrmXmlParser {
|
||||
private final MetadataImplementor metadata;
|
||||
|
||||
public OrmXmlParser(MetadataImplementor metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given xml configuration files and returns a updated annotation index
|
||||
*
|
||||
* @param mappings list of {@code XMLEntityMappings} created from the specified orm xml files
|
||||
* @param annotationIndex the annotation index based on scanned annotations
|
||||
*
|
||||
* @return a new updated annotation index, enhancing and modifying the existing ones according to the jpa xml rules
|
||||
*/
|
||||
public Index parseAndUpdateIndex(List<JaxbRoot<XMLEntityMappings>> mappings, Index annotationIndex) {
|
||||
List<XMLEntityMappings> list = new ArrayList<XMLEntityMappings>( mappings.size() );
|
||||
for ( JaxbRoot<XMLEntityMappings> jaxbRoot : mappings ) {
|
||||
list.add( jaxbRoot.getRoot() );
|
||||
}
|
||||
return new EntityMappingsMocker( list, annotationIndex, metadata.getServiceRegistry() ).mockNewIndex();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
|
||||
* third-party contributors as indicated by either @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.annotations.xml.mocker;
|
||||
|
||||
/**
|
||||
* Mocker classes to create mock JPA annotations from orm.xml
|
||||
*/
|
|
@ -57,7 +57,7 @@ public class PersisterClassResolverInitiator implements BasicServiceInitiator<Pe
|
|||
|
||||
final Class<? extends PersisterClassResolver> customImplClass = Class.class.isInstance( customImpl )
|
||||
? (Class<? extends PersisterClassResolver>) customImpl
|
||||
: registry.getService( ClassLoaderService.class ).classForName( customImpl.toString() );
|
||||
: locate( registry, customImpl.toString() );
|
||||
|
||||
try {
|
||||
return customImplClass.newInstance();
|
||||
|
@ -66,4 +66,8 @@ public class PersisterClassResolverInitiator implements BasicServiceInitiator<Pe
|
|||
throw new ServiceException( "Could not initialize custom PersisterClassResolver impl [" + customImplClass.getName() + "]", e );
|
||||
}
|
||||
}
|
||||
|
||||
private Class<? extends PersisterClassResolver> locate(ServiceRegistryImplementor registry, String className) {
|
||||
return registry.getService( ClassLoaderService.class ).classForName( className );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class PersisterFactoryInitiator implements BasicServiceInitiator<Persiste
|
|||
|
||||
final Class<? extends PersisterFactory> customImplClass = Class.class.isInstance( customImpl )
|
||||
? ( Class<? extends PersisterFactory> ) customImpl
|
||||
: registry.getService( ClassLoaderService.class ).classForName( customImpl.toString() );
|
||||
: locate( registry, customImpl.toString() );
|
||||
try {
|
||||
return customImplClass.newInstance();
|
||||
}
|
||||
|
@ -66,4 +66,8 @@ public class PersisterFactoryInitiator implements BasicServiceInitiator<Persiste
|
|||
throw new ServiceException( "Could not initialize custom PersisterFactory impl [" + customImplClass.getName() + "]", e );
|
||||
}
|
||||
}
|
||||
|
||||
private Class<? extends PersisterFactory> locate(ServiceRegistryImplementor registry, String className) {
|
||||
return registry.getService( ClassLoaderService.class ).classForName( className );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,10 +121,11 @@ public class ClassLoaderServiceImpl implements ClassLoaderService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Class classForName(String className) {
|
||||
@SuppressWarnings( {"unchecked"})
|
||||
public <T> Class<T> classForName(String className) {
|
||||
for ( ClassLoader classLoader : classLoadingClassLoaders ) {
|
||||
try {
|
||||
return classLoader.loadClass( className );
|
||||
return (Class<T>) classLoader.loadClass( className );
|
||||
}
|
||||
catch ( Exception ignore) {
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public interface ClassLoaderService extends Service {
|
|||
*
|
||||
* @throws ClassLoadingException Indicates the class could not be found
|
||||
*/
|
||||
public Class classForName(String className);
|
||||
public <T> Class<T> classForName(String className);
|
||||
|
||||
/**
|
||||
* Locate a resource by name (classpath lookup)
|
||||
|
|
|
@ -21,13 +21,11 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations;
|
||||
|
||||
package org.hibernate.metamodel.source.annotations.entity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.classmate.MemberResolver;
|
||||
import com.fasterxml.classmate.ResolvedType;
|
||||
import com.fasterxml.classmate.ResolvedTypeWithMembers;
|
||||
import com.fasterxml.classmate.TypeResolver;
|
||||
|
@ -35,52 +33,46 @@ import org.jboss.jandex.ClassInfo;
|
|||
import org.jboss.jandex.DotName;
|
||||
import org.jboss.jandex.Index;
|
||||
|
||||
import org.hibernate.cfg.EJB3NamingStrategy;
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.metamodel.binder.source.MappingDefaults;
|
||||
import org.hibernate.metamodel.binder.source.MetadataImplementor;
|
||||
import org.hibernate.metamodel.binder.source.annotations.AnnotationsBindingContext;
|
||||
import org.hibernate.metamodel.domain.JavaType;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||
|
||||
/**
|
||||
* Helper class for keeping some context information needed during the processing of mapped classes.
|
||||
*
|
||||
* @author Hardy Ferentschik
|
||||
*/
|
||||
public class AnnotationBindingContext {
|
||||
private final TypeResolver typeResolver;
|
||||
private final ServiceRegistry serviceRegistry;
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class AnnotationsBindingContextImpl implements AnnotationsBindingContext {
|
||||
private final Index index;
|
||||
private final Map<Class<?>, ResolvedType> resolvedTypeCache;
|
||||
private final BasicServiceRegistryImpl serviceRegistry;
|
||||
|
||||
private ClassLoaderService classLoaderService;
|
||||
private final TypeResolver typeResolver = new TypeResolver();
|
||||
private final Map<Class<?>, ResolvedType> resolvedTypeCache = new HashMap<Class<?>, ResolvedType>();
|
||||
|
||||
public AnnotationBindingContext(Index index, ServiceRegistry serviceRegistry) {
|
||||
public AnnotationsBindingContextImpl(Index index, BasicServiceRegistryImpl serviceRegistry) {
|
||||
this.index = index;
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
this.typeResolver = new TypeResolver();
|
||||
this.resolvedTypeCache = new HashMap<Class<?>, ResolvedType>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Index getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public ClassLoaderService classLoaderService() {
|
||||
if ( classLoaderService == null ) {
|
||||
classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||
}
|
||||
return classLoaderService;
|
||||
}
|
||||
|
||||
public ClassInfo getClassInfo(String className) {
|
||||
DotName dotName = DotName.createSimple( className );
|
||||
@Override
|
||||
public ClassInfo getClassInfo(String name) {
|
||||
DotName dotName = DotName.createSimple( name );
|
||||
return index.getClassByName( dotName );
|
||||
}
|
||||
|
||||
public Class<?> loadClass(String className) {
|
||||
return classLoaderService.classForName( className );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolveAllTypes(String className) {
|
||||
// the resolved type for the top level class in the hierarchy
|
||||
Class<?> clazz = classLoaderService().classForName( className );
|
||||
Class<?> clazz = locateClassByName( className );
|
||||
ResolvedType resolvedType = typeResolver.resolve( clazz );
|
||||
while ( resolvedType != null ) {
|
||||
// todo - check whether there is already something in the map
|
||||
|
@ -92,15 +84,48 @@ public class AnnotationBindingContext {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResolvedType getResolvedType(Class<?> clazz) {
|
||||
// todo - error handling
|
||||
return resolvedTypeCache.get( clazz );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResolvedTypeWithMembers resolveMemberTypes(ResolvedType type) {
|
||||
MemberResolver memberResolver = new MemberResolver( typeResolver );
|
||||
return memberResolver.resolve( type, null, null );
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceRegistry getServiceRegistry() {
|
||||
return serviceRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamingStrategy getNamingStrategy() {
|
||||
return EJB3NamingStrategy.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MappingDefaults getMappingDefaults() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataImplementor getMetadataImplementor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Class<T> locateClassByName(String name) {
|
||||
return serviceRegistry.getService( ClassLoaderService.class ).classForName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaType makeJavaType(String className) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGloballyQuotedIdentifiers() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -39,10 +39,11 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.metamodel.binder.source.annotations.AnnotationsBindingContext;
|
||||
import org.hibernate.metamodel.binder.source.annotations.ConfiguredClassHierarchyBuilder;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClassHierarchy;
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
import org.hibernate.metamodel.source.annotations.AnnotationBindingContext;
|
||||
import org.hibernate.metamodel.source.annotations.util.ConfiguredClassHierarchyBuilder;
|
||||
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.service.ServiceRegistryBuilder;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||
|
@ -85,7 +86,7 @@ public class TableNameTest extends BaseUnitTestCase {
|
|||
}
|
||||
|
||||
Index index = JandexHelper.indexForClass( service, A.class, B.class );
|
||||
AnnotationBindingContext context = new AnnotationBindingContext( index, serviceRegistry );
|
||||
AnnotationsBindingContext context = new AnnotationsBindingContextImpl( index, serviceRegistry );
|
||||
Set<ConfiguredClassHierarchy<EntityClass>> hierarchies = ConfiguredClassHierarchyBuilder.createEntityHierarchies(
|
||||
context
|
||||
);
|
||||
|
@ -133,7 +134,7 @@ public class TableNameTest extends BaseUnitTestCase {
|
|||
}
|
||||
|
||||
Index index = JandexHelper.indexForClass( service, A.class, B.class );
|
||||
AnnotationBindingContext context = new AnnotationBindingContext( index, serviceRegistry );
|
||||
AnnotationsBindingContext context = new AnnotationsBindingContextImpl( index, serviceRegistry );
|
||||
Set<ConfiguredClassHierarchy<EntityClass>> hierarchies = ConfiguredClassHierarchyBuilder.createEntityHierarchies(
|
||||
context
|
||||
);
|
||||
|
@ -182,7 +183,7 @@ public class TableNameTest extends BaseUnitTestCase {
|
|||
}
|
||||
|
||||
Index index = JandexHelper.indexForClass( service, B.class, A.class );
|
||||
AnnotationBindingContext context = new AnnotationBindingContext( index, serviceRegistry );
|
||||
AnnotationsBindingContextImpl context = new AnnotationsBindingContextImpl( index, serviceRegistry );
|
||||
Set<ConfiguredClassHierarchy<EntityClass>> hierarchies = ConfiguredClassHierarchyBuilder.createEntityHierarchies(
|
||||
context
|
||||
);
|
||||
|
|
|
@ -32,8 +32,9 @@ import org.hibernate.annotations.FetchMode;
|
|||
import org.hibernate.annotations.FetchProfile;
|
||||
import org.hibernate.annotations.FetchProfiles;
|
||||
import org.hibernate.metamodel.MetadataSources;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.global.FetchProfileBinder;
|
||||
import org.hibernate.metamodel.binder.source.internal.MetadataImpl;
|
||||
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.service.ServiceRegistryBuilder;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
||||
* 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.
|
||||
|
@ -31,8 +31,10 @@ import org.jboss.jandex.Index;
|
|||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import org.hibernate.metamodel.source.annotations.AnnotationBindingContext;
|
||||
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClassHierarchy;
|
||||
import org.hibernate.metamodel.binder.source.annotations.ConfiguredClassHierarchyBuilder;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClassHierarchy;
|
||||
import org.hibernate.metamodel.source.annotations.entity.AnnotationsBindingContextImpl;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EmbeddableClass;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EntityClass;
|
||||
import org.hibernate.service.ServiceRegistryBuilder;
|
||||
|
@ -58,7 +60,7 @@ public abstract class BaseAnnotationIndexTestCase extends BaseUnitTestCase {
|
|||
|
||||
public Set<ConfiguredClassHierarchy<EntityClass>> createEntityHierarchies(Class<?>... clazz) {
|
||||
Index index = JandexHelper.indexForClass( serviceRegistry.getService( ClassLoaderService.class ), clazz );
|
||||
AnnotationBindingContext context = new AnnotationBindingContext( index, serviceRegistry );
|
||||
AnnotationsBindingContextImpl context = new AnnotationsBindingContextImpl( index, serviceRegistry );
|
||||
return ConfiguredClassHierarchyBuilder.createEntityHierarchies( context );
|
||||
}
|
||||
|
||||
|
@ -67,7 +69,7 @@ public abstract class BaseAnnotationIndexTestCase extends BaseUnitTestCase {
|
|||
serviceRegistry.getService( ClassLoaderService.class ),
|
||||
configuredClasses
|
||||
);
|
||||
AnnotationBindingContext context = new AnnotationBindingContext( index, serviceRegistry );
|
||||
AnnotationsBindingContextImpl context = new AnnotationsBindingContextImpl( index, serviceRegistry );
|
||||
return ConfiguredClassHierarchyBuilder.createEmbeddableHierarchy( configuredClasses[0], accessType, context );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@ import org.junit.Test;
|
|||
|
||||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClassHierarchy;
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClassHierarchy;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EmbeddableClass;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EntityClass;
|
||||
|
||||
|
|
|
@ -35,9 +35,9 @@ import org.jboss.jandex.ClassInfo;
|
|||
import org.jboss.jandex.DotName;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClass;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClassHierarchy;
|
||||
import org.hibernate.metamodel.source.annotations.attribute.MappedAttribute;
|
||||
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClass;
|
||||
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClassHierarchy;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EntityClass;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
|
|
@ -42,11 +42,13 @@ import org.junit.Test;
|
|||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.annotations.NamedNativeQuery;
|
||||
import org.hibernate.metamodel.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
import org.hibernate.service.ServiceRegistryBuilder;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
|
|
@ -32,9 +32,9 @@ import org.junit.Test;
|
|||
|
||||
import org.hibernate.annotations.Parameter;
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClass;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClassHierarchy;
|
||||
import org.hibernate.metamodel.source.annotations.attribute.MappedAttribute;
|
||||
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClass;
|
||||
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClassHierarchy;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EntityClass;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
|
|
@ -38,6 +38,8 @@ import org.jboss.jandex.Indexer;
|
|||
|
||||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.EntityMappingsMocker;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.IndexBuilder;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLEntityMappings;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
|
|
|
@ -29,11 +29,14 @@ import org.jboss.jandex.DotName;
|
|||
import org.jboss.jandex.Index;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.EntityMappingsMocker;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.EntityMocker;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.IndexBuilder;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLAttributes;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLEntity;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLGeneratedValue;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLId;
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
|
|
@ -18,8 +18,11 @@ import org.jboss.jandex.DotName;
|
|||
import org.jboss.jandex.Index;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.DefaultConfigurationHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.EntityMappingsMocker;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.SchemaAware;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLEntity;
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
|
@ -28,8 +28,8 @@ import org.jboss.jandex.DotName;
|
|||
import org.jboss.jandex.Index;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.source.annotations.xml.PseudoJpaDotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.PseudoJpaDotNames;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.IndexBuilder;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue