HHH-8959 : Change values of type ValueHolder<Class> to JavaClassReference
This commit is contained in:
parent
f84cd309c1
commit
79379d598e
|
@ -162,7 +162,7 @@ class TypeSafeActivator {
|
|||
// Hardy : I started working on this as part of a big metamodel clean up I am doing, but this got to be too
|
||||
// much of a rabbit hole. - Steve
|
||||
for ( EntityBinding entityBinding : activationContext.getMetadata().getEntityBindings() ) {
|
||||
final String className = entityBinding.getEntity().getClassName();
|
||||
final String className = entityBinding.getEntity().getClassReference().getName();
|
||||
|
||||
if ( className == null || className.length() == 0 ) {
|
||||
continue;
|
||||
|
@ -217,7 +217,8 @@ class TypeSafeActivator {
|
|||
if ( attribute.isSingular() ) {
|
||||
final SingularAttribute singularAttribute = (SingularAttribute) attribute;
|
||||
if ( singularAttribute.getSingularAttributeType().isAggregate() ) {
|
||||
final Class componentClass = singularAttribute.getSingularAttributeType().getClassReference();
|
||||
final Class componentClass =
|
||||
singularAttribute.getSingularAttributeType().getClassReference().getResolvedClass();
|
||||
final boolean canSetNotNullOnColumns = activateNotNull && hasNotNull;
|
||||
applyDDL(
|
||||
prefix + propertyDesc.getPropertyName() + ".",
|
||||
|
|
|
@ -59,9 +59,7 @@ import org.hibernate.id.enhanced.TableGenerator;
|
|||
import org.hibernate.id.factory.IdentifierGeneratorFactory;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.FilterConfiguration;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.metamodel.internal.EntityHierarchyHelper.LocalBindingContextExecutionContext;
|
||||
import org.hibernate.metamodel.internal.EntityHierarchyHelper.LocalBindingContextExecutor;
|
||||
import org.hibernate.metamodel.internal.HibernateTypeHelper.ReflectedCollectionJavaTypes;
|
||||
|
@ -105,9 +103,10 @@ import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
|
|||
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding.NaturalIdMutability;
|
||||
import org.hibernate.metamodel.spi.binding.SingularNonAssociationAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.domain.Aggregate;
|
||||
import org.hibernate.metamodel.spi.domain.BasicType;
|
||||
import org.hibernate.metamodel.spi.domain.Entity;
|
||||
import org.hibernate.metamodel.spi.domain.IndexedPluralAttribute;
|
||||
import org.hibernate.metamodel.spi.domain.JavaType;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.metamodel.spi.domain.PluralAttribute;
|
||||
import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
||||
import org.hibernate.metamodel.spi.relational.Column;
|
||||
|
@ -261,13 +260,13 @@ public class Binder implements HelperContext {
|
|||
final String proxy = entitySource.getProxy();
|
||||
if ( proxy == null ) {
|
||||
if ( entitySource.isLazy() ) {
|
||||
entityBinding.setProxyInterfaceType( entityBinding.getEntity().getClassReferenceUnresolved() );
|
||||
entityBinding.setProxyInterfaceType( entityBinding.getEntity().getClassReference() );
|
||||
entityBinding.setLazy( true );
|
||||
}
|
||||
}
|
||||
else {
|
||||
entityBinding.setProxyInterfaceType(
|
||||
bindingContext().makeClassReference(
|
||||
bindingContext().makeJavaClassReference(
|
||||
bindingContext().qualifyClassName(
|
||||
proxy
|
||||
)
|
||||
|
@ -292,17 +291,18 @@ public class Binder implements HelperContext {
|
|||
new EntityBinding( inheritanceType, entityMode ) :
|
||||
new EntityBinding( superEntityBinding );
|
||||
// Create domain entity
|
||||
final String entityClassName = entityMode == EntityMode.POJO ? entitySource.getClassName() : null;
|
||||
LocalBindingContext bindingContext = bindingContext();
|
||||
entityBinding.setEntity(
|
||||
new Entity(
|
||||
entitySource.getEntityName(),
|
||||
entityClassName,
|
||||
bindingContext.makeClassReference( entityClassName ),
|
||||
superEntityBinding == null ? null : superEntityBinding.getEntity()
|
||||
)
|
||||
final JavaClassReference entityClassReference = entitySource.getClassName() == null ?
|
||||
null :
|
||||
bindingContext.makeJavaClassReference( entitySource.getClassName() );
|
||||
final Entity entity = new Entity(
|
||||
entitySource.getEntityName(),
|
||||
entityClassReference,
|
||||
superEntityBinding == null ? null : superEntityBinding.getEntity()
|
||||
);
|
||||
|
||||
entityBinding.setEntity( entity );
|
||||
|
||||
entityBinding.setEntityName( entitySource.getEntityName() );
|
||||
entityBinding.setJpaEntityName( entitySource.getJpaEntityName() ); //must before creating primary table
|
||||
entityBinding.setDynamicUpdate( entitySource.isDynamicUpdate() );
|
||||
|
@ -1166,12 +1166,18 @@ public class Binder implements HelperContext {
|
|||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Entity binding relates methods
|
||||
|
||||
private EntityBinding locateEntityBinding(
|
||||
final ValueHolder<Class<?>> entityJavaTypeValue,
|
||||
final JavaClassReference entityJavaClassReference,
|
||||
final String explicitEntityName) {
|
||||
final String referencedEntityName =
|
||||
explicitEntityName != null
|
||||
? explicitEntityName
|
||||
: entityJavaTypeValue.getValue().getName();
|
||||
final String referencedEntityName;
|
||||
if ( explicitEntityName != null ) {
|
||||
referencedEntityName = explicitEntityName;
|
||||
}
|
||||
else if ( entityJavaClassReference != null ) {
|
||||
referencedEntityName = entityJavaClassReference.getName();
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException( "explicitEntityName and entityJavaClassReference cannot both be null." );
|
||||
}
|
||||
return locateEntityBinding( referencedEntityName );
|
||||
}
|
||||
|
||||
|
@ -1646,30 +1652,25 @@ public class Binder implements HelperContext {
|
|||
final ComponentAttributeSource attributeSource,
|
||||
SingularAttribute attribute) {
|
||||
final Aggregate composite;
|
||||
final ValueHolder<Class<?>> defaultJavaClassReference;
|
||||
final String roleBase =
|
||||
attributeBindingContainer.getAttributeContainer().getRoleBaseName() + '.' + attributeSource.getPath();
|
||||
if ( attribute == null ) {
|
||||
if ( attributeSource.getClassName() != null ) {
|
||||
composite = new Aggregate(
|
||||
attributeSource.getPath(),
|
||||
attributeSource.getClassName(),
|
||||
attributeSource.getClassReference() != null ?
|
||||
attributeSource.getClassReference() :
|
||||
bindingContext().makeClassReference( attributeSource.getClassName() ),
|
||||
null
|
||||
);
|
||||
// no need for a default because there's an explicit class name provided
|
||||
final JavaClassReference aggregateJavaClassReference;
|
||||
if ( attributeSource.getClassReference() != null ) {
|
||||
aggregateJavaClassReference = attributeSource.getClassReference();
|
||||
}
|
||||
else {
|
||||
defaultJavaClassReference = createSingularAttributeJavaType(
|
||||
attributeBindingContainer.getClassReference(), attributeSource.getName()
|
||||
);
|
||||
composite = new Aggregate(
|
||||
attributeSource.getPath(),
|
||||
defaultJavaClassReference.getValue().getName(),
|
||||
defaultJavaClassReference,
|
||||
null
|
||||
aggregateJavaClassReference = typeHelper.determineJavaType(
|
||||
attributeSource,
|
||||
attributeBindingContainer.getAttributeContainer()
|
||||
);
|
||||
}
|
||||
composite = new Aggregate(
|
||||
roleBase,
|
||||
attributeSource.getPath(),
|
||||
aggregateJavaClassReference,
|
||||
null
|
||||
);
|
||||
attribute = attributeBindingContainer.getAttributeContainer().createCompositeAttribute(
|
||||
attributeSource.getName(),
|
||||
composite
|
||||
|
@ -1722,9 +1723,12 @@ public class Binder implements HelperContext {
|
|||
}
|
||||
throwExceptionIfNotFoundIgnored( attributeSource.isNotFoundAnException() );
|
||||
|
||||
final ValueHolder<Class<?>> referencedEntityJavaTypeValue = createSingularAttributeJavaType( attribute );
|
||||
final JavaClassReference referencedEntityJavaClassReference = typeHelper.determineJavaType(
|
||||
attributeSource,
|
||||
attributeBindingContainer.getAttributeContainer()
|
||||
);
|
||||
final EntityBinding referencedEntityBinding = locateEntityBinding(
|
||||
referencedEntityJavaTypeValue,
|
||||
referencedEntityJavaClassReference,
|
||||
attributeSource.getReferencedEntityName()
|
||||
);
|
||||
|
||||
|
@ -1802,7 +1806,7 @@ public class Binder implements HelperContext {
|
|||
typeHelper.bindHibernateTypeDescriptor(
|
||||
attributeBinding.getHibernateTypeDescriptor(),
|
||||
attributeSource.getTypeInformation(),
|
||||
referencedEntityJavaTypeValue.getValue().getName(),
|
||||
referencedEntityJavaClassReference,
|
||||
resolvedType
|
||||
);
|
||||
|
||||
|
@ -1823,10 +1827,12 @@ public class Binder implements HelperContext {
|
|||
if ( attribute == null ) {
|
||||
attribute = createSingularAttribute( attributeBindingContainer, attributeSource );
|
||||
}
|
||||
|
||||
final ValueHolder<Class<?>> referencedEntityJavaTypeValue = createSingularAttributeJavaType( attribute );
|
||||
final JavaClassReference referencedEntityJavaClassReference = typeHelper.determineJavaType(
|
||||
attributeSource,
|
||||
attributeBindingContainer.getAttributeContainer()
|
||||
);
|
||||
final EntityBinding referencedEntityBinding = locateEntityBinding(
|
||||
referencedEntityJavaTypeValue,
|
||||
referencedEntityJavaClassReference,
|
||||
attributeSource.getReferencedEntityName()
|
||||
);
|
||||
|
||||
|
@ -1919,7 +1925,7 @@ public class Binder implements HelperContext {
|
|||
typeHelper.bindHibernateTypeDescriptor(
|
||||
attributeBinding.getHibernateTypeDescriptor(),
|
||||
attributeSource.getTypeInformation(),
|
||||
referencedEntityJavaTypeValue.getValue().getName(),
|
||||
referencedEntityJavaClassReference,
|
||||
resolvedType
|
||||
);
|
||||
if ( !attributeBinding.getRelationalValueBindings().isEmpty() ) {
|
||||
|
@ -2047,10 +2053,18 @@ public class Binder implements HelperContext {
|
|||
// Cannot resolve plural attribute type until after the element binding is bound.
|
||||
final Type resolvedType = typeHelper.resolvePluralType( attributeBinding, attributeSource, nature );
|
||||
final HibernateTypeDescriptor hibernateTypeDescriptor = attributeBinding.getHibernateTypeDescriptor();
|
||||
JavaClassReference defaultCollectionClassReference = typeHelper.reflectedCollectionClassReference(
|
||||
reflectedCollectionJavaTypes
|
||||
);
|
||||
if ( defaultCollectionClassReference == null ) {
|
||||
defaultCollectionClassReference = bindingContext().makeJavaClassReference(
|
||||
attributeSource.getNature().reportedJavaType()
|
||||
);
|
||||
}
|
||||
typeHelper.bindHibernateTypeDescriptor(
|
||||
hibernateTypeDescriptor,
|
||||
attributeSource.getTypeInformation(),
|
||||
HibernateTypeHelper.defaultCollectionJavaTypeName( reflectedCollectionJavaTypes, attributeSource ),
|
||||
defaultCollectionClassReference,
|
||||
resolvedType
|
||||
);
|
||||
if ( attributeBinding.hasIndex() ) {
|
||||
|
@ -2174,11 +2188,11 @@ public class Binder implements HelperContext {
|
|||
private void bindBasicCollectionElement(
|
||||
final BasicPluralAttributeElementBinding elementBinding,
|
||||
final BasicPluralAttributeElementSource elementSource,
|
||||
final String defaultElementJavaTypeName) {
|
||||
final JavaClassReference defaultElementJavaClassReference) {
|
||||
bindBasicPluralElementRelationalValues( elementSource, elementBinding );
|
||||
typeHelper.bindBasicCollectionElementType( elementBinding, elementSource, defaultElementJavaTypeName );
|
||||
typeHelper.bindBasicCollectionElementType( elementBinding, elementSource, defaultElementJavaClassReference );
|
||||
elementBinding.getPluralAttributeBinding().getAttribute().setElementType(
|
||||
bindingContext().makeJavaType( elementBinding.getHibernateTypeDescriptor().getJavaTypeName() )
|
||||
bindingContext().makeDomainType( elementBinding.getHibernateTypeDescriptor().getClassReference().getName() )
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2215,33 +2229,26 @@ public class Binder implements HelperContext {
|
|||
private void bindCompositeCollectionElement(
|
||||
final CompositePluralAttributeElementBinding elementBinding,
|
||||
final CompositePluralAttributeElementSource elementSource,
|
||||
final String defaultElementJavaTypeName) {
|
||||
final JavaClassReference reflectedElementJavaClassReference) {
|
||||
final PluralAttributeBinding pluralAttributeBinding = elementBinding.getPluralAttributeBinding();
|
||||
ValueHolder<Class<?>> defaultElementJavaClassReference = null;
|
||||
// Create the aggregate type
|
||||
// TODO: aggregateName should be set to elementSource.getPath() (which is currently not implemented)
|
||||
// or Binder should define AttributeBindingContainer paths instead.
|
||||
String aggregateName = pluralAttributeBinding.getAttribute().getRole() + ".element";
|
||||
final Aggregate aggregate;
|
||||
if ( elementSource.getClassName() != null ) {
|
||||
aggregate = new Aggregate(
|
||||
aggregateName,
|
||||
elementSource.getClassName(),
|
||||
elementSource.getClassReference() != null ?
|
||||
elementSource.getClassReference() :
|
||||
bindingContext().makeClassReference( elementSource.getClassName() ),
|
||||
null
|
||||
);
|
||||
final String aggregateName = "element";
|
||||
String roleBase = pluralAttributeBinding.getAttribute().getRole() + '.' + aggregateName;
|
||||
final JavaClassReference elementClassReference;
|
||||
if ( elementSource.getClassReference() != null ) {
|
||||
elementClassReference = elementSource.getClassReference();
|
||||
}
|
||||
else {
|
||||
defaultElementJavaClassReference = bindingContext().makeClassReference( defaultElementJavaTypeName );
|
||||
aggregate = new Aggregate(
|
||||
aggregateName,
|
||||
defaultElementJavaClassReference.getValue().getName(),
|
||||
defaultElementJavaClassReference,
|
||||
null
|
||||
);
|
||||
elementClassReference = reflectedElementJavaClassReference;
|
||||
}
|
||||
final Aggregate aggregate = new Aggregate(
|
||||
roleBase,
|
||||
aggregateName,
|
||||
elementClassReference,
|
||||
null
|
||||
);
|
||||
final SingularAttribute parentAttribute =
|
||||
StringHelper.isEmpty( elementSource.getParentReferenceAttributeName() ) ?
|
||||
null :
|
||||
|
@ -2264,9 +2271,9 @@ public class Binder implements HelperContext {
|
|||
// TODO: binding the HibernateTypeDescriptor should be simplified since we know the class name already
|
||||
typeHelper.bindHibernateTypeDescriptor(
|
||||
elementBinding.getHibernateTypeDescriptor(),
|
||||
aggregate.getClassName(),
|
||||
aggregate.getClassReference().getName(),
|
||||
null,
|
||||
defaultElementJavaClassReference == null ? null : defaultElementJavaClassReference.getValue().getName(),
|
||||
reflectedElementJavaClassReference == null ? null : reflectedElementJavaClassReference,
|
||||
resolvedType
|
||||
);
|
||||
/**
|
||||
|
@ -2298,14 +2305,14 @@ public class Binder implements HelperContext {
|
|||
private void bindEntityAttributePluralAttributeIndex(
|
||||
final IndexedPluralAttributeBinding attributeBinding,
|
||||
final EntityAttributePluralAttributeIndexSource indexSource,
|
||||
final String defaultIndexJavaTypeName) {
|
||||
final JavaClassReference defaultIndexJavaClassReference) {
|
||||
throw new NotYetImplementedException( "Plural attribute index that is an attribute of the referenced entity is not supported yet." );
|
||||
}
|
||||
|
||||
private void bindBasicCollectionIndex(
|
||||
final IndexedPluralAttributeBinding attributeBinding,
|
||||
final BasicPluralAttributeIndexSource indexSource,
|
||||
final String defaultIndexJavaTypeName) {
|
||||
final JavaClassReference defaultIndexJavaClassReference) {
|
||||
final BasicPluralAttributeIndexBinding indexBinding =
|
||||
(BasicPluralAttributeIndexBinding) attributeBinding.getPluralAttributeIndexBinding();
|
||||
// TODO: need to resolve default column names.
|
||||
|
@ -2324,7 +2331,7 @@ public class Binder implements HelperContext {
|
|||
typeHelper.bindHibernateTypeDescriptor(
|
||||
indexBinding.getHibernateTypeDescriptor(),
|
||||
indexSource.getTypeInformation(),
|
||||
defaultIndexJavaTypeName
|
||||
defaultIndexJavaClassReference
|
||||
);
|
||||
typeHelper.bindJdbcDataType(
|
||||
indexBinding.getHibernateTypeDescriptor().getResolvedTypeMapping(),
|
||||
|
@ -2332,43 +2339,46 @@ public class Binder implements HelperContext {
|
|||
);
|
||||
IndexedPluralAttribute indexedPluralAttribute =
|
||||
(IndexedPluralAttribute) indexBinding.getIndexedPluralAttributeBinding().getAttribute();
|
||||
indexedPluralAttribute.setIndexType(
|
||||
bindingContext().makeJavaType( indexBinding.getHibernateTypeDescriptor().getJavaTypeName() )
|
||||
);
|
||||
|
||||
final HibernateTypeDescriptor hibernateTypeDescriptor = indexBinding.getHibernateTypeDescriptor();
|
||||
final BasicType basicType;
|
||||
if ( hibernateTypeDescriptor.getExplicitTypeName() != null ) {
|
||||
basicType = new BasicType(
|
||||
hibernateTypeDescriptor.getExplicitTypeName(),
|
||||
hibernateTypeDescriptor.getClassReference()
|
||||
);
|
||||
}
|
||||
else {
|
||||
basicType = new BasicType( hibernateTypeDescriptor.getClassReference() );
|
||||
}
|
||||
indexedPluralAttribute.setIndexType( basicType );
|
||||
}
|
||||
|
||||
private void bindCompositeCollectionIndex(
|
||||
final CompositePluralAttributeIndexBinding indexBinding,
|
||||
final IndexedPluralAttributeSource indexedPluralAttributeSource,
|
||||
final String defaultIndexJavaTypeName) {
|
||||
final JavaClassReference reflectedIndexJavaClassReference) {
|
||||
final PluralAttributeBinding pluralAttributeBinding = indexBinding.getIndexedPluralAttributeBinding();
|
||||
final CompositePluralAttributeIndexSource indexSource =
|
||||
(CompositePluralAttributeIndexSource) indexedPluralAttributeSource.getIndexSource();
|
||||
ValueHolder<Class<?>> defaultElementJavaClassReference = null;
|
||||
final JavaClassReference indexJavaClassReference;
|
||||
if ( indexSource.getClassReference() != null ) {
|
||||
indexJavaClassReference = indexSource.getClassReference();
|
||||
}
|
||||
else {
|
||||
indexJavaClassReference = reflectedIndexJavaClassReference;
|
||||
}
|
||||
// Create the aggregate type
|
||||
// TODO: aggregateName should be set to elementSource.getPath() (which is currently not implemented)
|
||||
// or Binder should define AttributeBindingContainer paths instead.
|
||||
String aggregateName = pluralAttributeBinding.getAttribute().getRole() + ".index";
|
||||
final Aggregate aggregate;
|
||||
if ( indexSource.getClassName() != null ) {
|
||||
aggregate = new Aggregate(
|
||||
aggregateName,
|
||||
indexSource.getClassName(),
|
||||
indexSource.getClassReference() != null ?
|
||||
indexSource.getClassReference() :
|
||||
bindingContext().makeClassReference( indexSource.getClassName() ),
|
||||
null
|
||||
);
|
||||
}
|
||||
else {
|
||||
defaultElementJavaClassReference = bindingContext().makeClassReference( defaultIndexJavaTypeName );
|
||||
aggregate = new Aggregate(
|
||||
aggregateName,
|
||||
defaultElementJavaClassReference.getValue().getName(),
|
||||
defaultElementJavaClassReference,
|
||||
null
|
||||
);
|
||||
}
|
||||
final String aggregateName = "index";
|
||||
String roleBase = pluralAttributeBinding.getAttribute().getRole() + '.' + aggregateName;
|
||||
final Aggregate aggregate = new Aggregate(
|
||||
roleBase,
|
||||
aggregateName,
|
||||
indexJavaClassReference,
|
||||
null
|
||||
);
|
||||
final CompositeAttributeBindingContainer compositeAttributeBindingContainer =
|
||||
indexBinding.createCompositeAttributeBindingContainer(
|
||||
aggregate,
|
||||
|
@ -2384,9 +2394,9 @@ public class Binder implements HelperContext {
|
|||
// TODO: binding the HibernateTypeDescriptor should be simplified since we know the class name already
|
||||
typeHelper.bindHibernateTypeDescriptor(
|
||||
indexBinding.getHibernateTypeDescriptor(),
|
||||
aggregate.getClassName(),
|
||||
aggregate.getClassReference().getName(),
|
||||
null,
|
||||
defaultElementJavaClassReference == null ? null : defaultElementJavaClassReference.getValue().getName(),
|
||||
indexJavaClassReference == null ? null : indexJavaClassReference,
|
||||
resolvedType
|
||||
);
|
||||
IndexedPluralAttribute indexedPluralAttribute =
|
||||
|
@ -2398,7 +2408,7 @@ public class Binder implements HelperContext {
|
|||
final OneToManyPluralAttributeElementBinding elementBinding,
|
||||
final OneToManyPluralAttributeElementSource elementSource,
|
||||
final EntityBinding referencedEntityBinding,
|
||||
final String defaultElementJavaTypeName) {
|
||||
final JavaClassReference defaultElementJavaClassReference) {
|
||||
throwExceptionIfNotFoundIgnored( elementSource.isNotFoundAnException() );
|
||||
elementBinding.setElementEntityIdentifier(
|
||||
referencedEntityBinding.getKeyRelationalValueBindings()
|
||||
|
@ -2414,18 +2424,18 @@ public class Binder implements HelperContext {
|
|||
false
|
||||
);
|
||||
final HibernateTypeDescriptor hibernateTypeDescriptor = elementBinding.getHibernateTypeDescriptor();
|
||||
final String elementJavaTypeName;
|
||||
if ( defaultElementJavaTypeName != null ) {
|
||||
elementJavaTypeName = defaultElementJavaTypeName;
|
||||
final JavaClassReference elementJavaClassReference;
|
||||
if ( defaultElementJavaClassReference != null ) {
|
||||
elementJavaClassReference = defaultElementJavaClassReference;
|
||||
}
|
||||
else {
|
||||
elementJavaTypeName = referencedEntityBinding.getClassReference().getName();
|
||||
elementJavaClassReference = referencedEntityBinding.getClassReference();
|
||||
}
|
||||
typeHelper.bindHibernateTypeDescriptor(
|
||||
hibernateTypeDescriptor,
|
||||
referencedEntityBinding.getEntity().getName(),
|
||||
null,
|
||||
elementJavaTypeName,
|
||||
elementJavaClassReference,
|
||||
resolvedElementType
|
||||
);
|
||||
// no need to bind JDBC data types because element is referenced EntityBinding's ID
|
||||
|
@ -2437,7 +2447,7 @@ public class Binder implements HelperContext {
|
|||
final ManyToManyPluralAttributeElementBinding elementBinding,
|
||||
final ManyToManyPluralAttributeElementSource elementSource,
|
||||
final EntityBinding referencedEntityBinding,
|
||||
final String defaultElementJavaTypeName) {
|
||||
final JavaClassReference defaultElementJavaClassReference) {
|
||||
throwExceptionIfNotFoundIgnored( elementSource.isNotFoundAnException() );
|
||||
final TableSpecification collectionTable =
|
||||
elementBinding.getPluralAttributeBinding().getPluralAttributeKeyBinding().getCollectionTable();
|
||||
|
@ -2479,7 +2489,7 @@ public class Binder implements HelperContext {
|
|||
elementBinding,
|
||||
elementSource,
|
||||
referencedEntityBinding,
|
||||
defaultElementJavaTypeName
|
||||
defaultElementJavaClassReference
|
||||
);
|
||||
elementBinding.getPluralAttributeBinding().getAttribute().setElementType( referencedEntityBinding.getEntity() );
|
||||
elementBinding.setCascadeStyle( determineCascadeStyle( elementSource.getCascadeStyles() ) );
|
||||
|
@ -2538,14 +2548,14 @@ public class Binder implements HelperContext {
|
|||
final IndexedPluralAttributeSource attributeSource,
|
||||
final IndexedPluralAttributeBinding attributeBinding,
|
||||
final ReflectedCollectionJavaTypes reflectedCollectionJavaTypes) {
|
||||
final String defaultCollectionIndexJavaTypeName =
|
||||
HibernateTypeHelper.defaultCollectionIndexJavaTypeName( reflectedCollectionJavaTypes );
|
||||
final JavaClassReference reflectedCollectionIndexJavaClassReference =
|
||||
typeHelper.reflectedCollectionIndexClassReference( reflectedCollectionJavaTypes );
|
||||
final PluralAttributeIndexSource indexSource = attributeSource.getIndexSource();
|
||||
if ( indexSource.isReferencedEntityAttribute() ) {
|
||||
bindEntityAttributePluralAttributeIndex(
|
||||
attributeBinding,
|
||||
(EntityAttributePluralAttributeIndexSource) indexSource,
|
||||
defaultCollectionIndexJavaTypeName
|
||||
reflectedCollectionIndexJavaClassReference
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
@ -2554,7 +2564,7 @@ public class Binder implements HelperContext {
|
|||
bindBasicCollectionIndex(
|
||||
attributeBinding,
|
||||
(BasicPluralAttributeIndexSource) attributeSource.getIndexSource(),
|
||||
defaultCollectionIndexJavaTypeName
|
||||
reflectedCollectionIndexJavaClassReference
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
@ -2562,7 +2572,7 @@ public class Binder implements HelperContext {
|
|||
bindCompositeCollectionIndex(
|
||||
(CompositePluralAttributeIndexBinding) attributeBinding.getPluralAttributeIndexBinding(),
|
||||
attributeSource,
|
||||
defaultCollectionIndexJavaTypeName
|
||||
reflectedCollectionIndexJavaClassReference
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
@ -2596,7 +2606,7 @@ public class Binder implements HelperContext {
|
|||
bindCompositeCollectionElement(
|
||||
(CompositePluralAttributeElementBinding) attributeBinding.getPluralAttributeElementBinding(),
|
||||
(CompositePluralAttributeElementSource) attributeSource.getElementSource(),
|
||||
HibernateTypeHelper.defaultCollectionElementJavaTypeName( reflectedCollectionJavaTypes )
|
||||
typeHelper.reflectedCollectionElementJavaType( reflectedCollectionJavaTypes )
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2606,14 +2616,10 @@ public class Binder implements HelperContext {
|
|||
final ReflectedCollectionJavaTypes reflectedCollectionJavaTypes) {
|
||||
final ManyToManyPluralAttributeElementSource elementSource =
|
||||
(ManyToManyPluralAttributeElementSource) attributeSource.getElementSource();
|
||||
final String defaultElementJavaTypeName = HibernateTypeHelper.defaultCollectionElementJavaTypeName(
|
||||
final JavaClassReference reflectedElementJavaClassReference = typeHelper.reflectedCollectionElementJavaType(
|
||||
reflectedCollectionJavaTypes
|
||||
);
|
||||
String referencedEntityName =
|
||||
elementSource.getReferencedEntityName() != null ?
|
||||
elementSource.getReferencedEntityName() :
|
||||
defaultElementJavaTypeName;
|
||||
if ( referencedEntityName == null ) {
|
||||
if ( elementSource.getReferencedEntityName() == null && reflectedElementJavaClassReference == null ) {
|
||||
throw bindingContext().makeMappingException(
|
||||
String.format(
|
||||
"The mapping for the entity associated with one-to-many attribute (%s) is undefined.",
|
||||
|
@ -2621,7 +2627,10 @@ public class Binder implements HelperContext {
|
|||
)
|
||||
);
|
||||
}
|
||||
EntityBinding referencedEntityBinding = locateEntityBinding( referencedEntityName );
|
||||
EntityBinding referencedEntityBinding = locateEntityBinding(
|
||||
reflectedElementJavaClassReference,
|
||||
elementSource.getReferencedEntityName()
|
||||
);
|
||||
ManyToManyPluralAttributeElementBinding manyToManyPluralAttributeElementBinding = (ManyToManyPluralAttributeElementBinding) attributeBinding
|
||||
.getPluralAttributeElementBinding();
|
||||
|
||||
|
@ -2640,7 +2649,7 @@ public class Binder implements HelperContext {
|
|||
manyToManyPluralAttributeElementBinding,
|
||||
(ManyToManyPluralAttributeElementSource) attributeSource.getElementSource(),
|
||||
referencedEntityBinding,
|
||||
defaultElementJavaTypeName
|
||||
reflectedElementJavaClassReference
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2650,14 +2659,10 @@ public class Binder implements HelperContext {
|
|||
final ReflectedCollectionJavaTypes reflectedCollectionJavaTypes) {
|
||||
final OneToManyPluralAttributeElementSource elementSource =
|
||||
(OneToManyPluralAttributeElementSource) attributeSource.getElementSource();
|
||||
final String defaultElementJavaTypeName = HibernateTypeHelper.defaultCollectionElementJavaTypeName(
|
||||
final JavaClassReference defaultElementJavaClassReference = typeHelper.reflectedCollectionElementJavaType(
|
||||
reflectedCollectionJavaTypes
|
||||
);
|
||||
String referencedEntityName =
|
||||
elementSource.getReferencedEntityName() != null ?
|
||||
elementSource.getReferencedEntityName() :
|
||||
defaultElementJavaTypeName;
|
||||
if ( referencedEntityName == null ) {
|
||||
if ( elementSource.getReferencedEntityName() == null && defaultElementJavaClassReference == null ) {
|
||||
throw bindingContext().makeMappingException(
|
||||
String.format(
|
||||
"The mapping for the entity associated with one-to-many attribute (%s) is undefined.",
|
||||
|
@ -2665,13 +2670,16 @@ public class Binder implements HelperContext {
|
|||
)
|
||||
);
|
||||
}
|
||||
EntityBinding referencedEntityBinding = locateEntityBinding( referencedEntityName );
|
||||
EntityBinding referencedEntityBinding = locateEntityBinding(
|
||||
defaultElementJavaClassReference,
|
||||
elementSource.getReferencedEntityName()
|
||||
);
|
||||
bindOneToManyCollectionKey( attributeBinding, attributeSource, referencedEntityBinding );
|
||||
bindOneToManyCollectionElement(
|
||||
(OneToManyPluralAttributeElementBinding) attributeBinding.getPluralAttributeElementBinding(),
|
||||
(OneToManyPluralAttributeElementSource) attributeSource.getElementSource(),
|
||||
referencedEntityBinding,
|
||||
defaultElementJavaTypeName
|
||||
defaultElementJavaClassReference
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2683,7 +2691,7 @@ public class Binder implements HelperContext {
|
|||
bindBasicCollectionElement(
|
||||
(BasicPluralAttributeElementBinding) attributeBinding.getPluralAttributeElementBinding(),
|
||||
(BasicPluralAttributeElementSource) attributeSource.getElementSource(),
|
||||
HibernateTypeHelper.defaultCollectionElementJavaTypeName( reflectedCollectionJavaTypes )
|
||||
typeHelper.reflectedCollectionElementJavaType( reflectedCollectionJavaTypes )
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3063,30 +3071,6 @@ public class Binder implements HelperContext {
|
|||
attributeBinding.getContainer().getPathBase() + '.' + attributeBinding.getAttribute().getName();
|
||||
}
|
||||
|
||||
private static ValueHolder<Class<?>> createSingularAttributeJavaType(
|
||||
final Class<?> attributeContainerClassReference,
|
||||
final String attributeName) {
|
||||
ValueHolder.DeferredInitializer<Class<?>> deferredInitializer =
|
||||
new ValueHolder.DeferredInitializer<Class<?>>() {
|
||||
@Override
|
||||
public Class<?> initialize() {
|
||||
return ReflectHelper.reflectedPropertyClass(
|
||||
attributeContainerClassReference,
|
||||
attributeName
|
||||
);
|
||||
}
|
||||
};
|
||||
return new ValueHolder<Class<?>>( deferredInitializer );
|
||||
}
|
||||
|
||||
private static ValueHolder<Class<?>> createSingularAttributeJavaType(
|
||||
final SingularAttribute attribute) {
|
||||
return createSingularAttributeJavaType(
|
||||
attribute.getAttributeContainer().getClassReference(),
|
||||
attribute.getName()
|
||||
);
|
||||
}
|
||||
|
||||
public static interface DefaultNamingStrategy {
|
||||
|
||||
String defaultName(NamingStrategy namingStrategy);
|
||||
|
|
|
@ -34,10 +34,7 @@ import java.util.Properties;
|
|||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.cfg.NotYetImplementedException;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.internal.util.beans.BeanInfoHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.metamodel.spi.MetadataImplementor;
|
||||
|
@ -56,6 +53,8 @@ import org.hibernate.metamodel.spi.binding.RelationalValueBinding;
|
|||
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.TypeDefinition;
|
||||
import org.hibernate.metamodel.spi.domain.Aggregate;
|
||||
import org.hibernate.metamodel.spi.domain.AttributeContainer;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.metamodel.spi.domain.PluralAttribute;
|
||||
import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
||||
import org.hibernate.metamodel.spi.relational.AbstractValue;
|
||||
|
@ -143,27 +142,41 @@ class HibernateTypeHelper {
|
|||
}
|
||||
}
|
||||
|
||||
static String defaultCollectionElementJavaTypeName(
|
||||
JavaClassReference reflectedCollectionElementJavaType(
|
||||
final ReflectedCollectionJavaTypes reflectedCollectionJavaTypes) {
|
||||
return reflectedCollectionJavaTypes != null ? reflectedCollectionJavaTypes.getCollectionElementTypeName() : null;
|
||||
if ( reflectedCollectionJavaTypes != null &&
|
||||
reflectedCollectionJavaTypes.getCollectionElementTypeName() != null ) {
|
||||
return bindingContext().makeJavaClassReference(
|
||||
reflectedCollectionJavaTypes.getCollectionElementTypeName()
|
||||
);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static String defaultCollectionIndexJavaTypeName(
|
||||
JavaClassReference reflectedCollectionIndexClassReference(
|
||||
final ReflectedCollectionJavaTypes reflectedCollectionJavaTypes) {
|
||||
return reflectedCollectionJavaTypes != null ? reflectedCollectionJavaTypes.getCollectionIndexTypeName() : null;
|
||||
if ( reflectedCollectionJavaTypes != null && reflectedCollectionJavaTypes.getCollectionIndexTypeName() != null ) {
|
||||
return bindingContext().makeJavaClassReference( reflectedCollectionJavaTypes.getCollectionIndexTypeName() );
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static String defaultCollectionJavaTypeName(
|
||||
final ReflectedCollectionJavaTypes reflectedCollectionJavaTypes,
|
||||
final PluralAttributeSource attributeSource) {
|
||||
return reflectedCollectionJavaTypes != null ? reflectedCollectionJavaTypes.getCollectionTypeName() : attributeSource
|
||||
.getNature()
|
||||
.reportedJavaType()
|
||||
.getName();
|
||||
JavaClassReference reflectedCollectionClassReference(
|
||||
final ReflectedCollectionJavaTypes reflectedCollectionJavaTypes) {
|
||||
if( reflectedCollectionJavaTypes != null && reflectedCollectionJavaTypes.getCollectionTypeName() != null ) {
|
||||
return bindingContext().makeJavaClassReference( reflectedCollectionJavaTypes.getCollectionTypeName() );
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
static ReflectedCollectionJavaTypes getReflectedCollectionJavaTypes(
|
||||
final PluralAttributeBinding attributeBinding) {
|
||||
return determineJavaType( attributeBinding.getAttribute() );
|
||||
return determineReflectedCollectionJavaTypes( attributeBinding.getAttribute() );
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -188,7 +201,7 @@ class HibernateTypeHelper {
|
|||
* Explicit type parameters defined in the mapping or resolved from refrenced attribute type.
|
||||
* <code>null</code> is accepted.
|
||||
*
|
||||
* @param defaultJavaTypeName
|
||||
* @param defaultJavaClassReference
|
||||
*
|
||||
* Attribute java type. <code>null</code> is accepted.
|
||||
*
|
||||
|
@ -200,7 +213,7 @@ class HibernateTypeHelper {
|
|||
final HibernateTypeDescriptor hibernateTypeDescriptor,
|
||||
final String explicitTypeName,
|
||||
final Map<String, String> explictTypeParameters,
|
||||
final String defaultJavaTypeName,
|
||||
final JavaClassReference defaultJavaClassReference,
|
||||
final Type resolvedType) {
|
||||
Type type;
|
||||
if ( resolvedType != null ) {
|
||||
|
@ -212,7 +225,7 @@ class HibernateTypeHelper {
|
|||
hibernateTypeDescriptor,
|
||||
explicitTypeName,
|
||||
explictTypeParameters,
|
||||
defaultJavaTypeName
|
||||
defaultJavaClassReference
|
||||
);
|
||||
//2. resolve hibernate type
|
||||
type = getHeuristicType(
|
||||
|
@ -227,12 +240,12 @@ class HibernateTypeHelper {
|
|||
//3. now set hibernateTypeDescripter's ResolvedTypeMapping and defaultJavaType (if not yet)
|
||||
hibernateTypeDescriptor.setResolvedTypeMapping( type );
|
||||
|
||||
if ( hibernateTypeDescriptor.getJavaTypeName() == null ) {
|
||||
if ( defaultJavaTypeName != null ) {
|
||||
hibernateTypeDescriptor.setJavaTypeName( defaultJavaTypeName );
|
||||
if ( hibernateTypeDescriptor.getClassReference() == null ) {
|
||||
if ( defaultJavaClassReference != null ) {
|
||||
hibernateTypeDescriptor.setClassReference( defaultJavaClassReference );
|
||||
}
|
||||
else if ( type != null ) {
|
||||
hibernateTypeDescriptor.setJavaTypeName( type.getReturnedClass().getName() );
|
||||
else if ( type != null && ! type.isAssociationType() ) {
|
||||
hibernateTypeDescriptor.setClassReference( bindingContext().makeJavaClassReference( type.getReturnedClass() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -241,12 +254,12 @@ class HibernateTypeHelper {
|
|||
final HibernateTypeDescriptor hibernateTypeDescriptor,
|
||||
final String explicitTypeName,
|
||||
final Map<String, String> explictTypeParameters,
|
||||
final String defaultJavaTypeName) {
|
||||
final JavaClassReference defaultJavaClassReference) {
|
||||
bindHibernateTypeDescriptor(
|
||||
hibernateTypeDescriptor,
|
||||
explicitTypeName,
|
||||
explictTypeParameters,
|
||||
defaultJavaTypeName,
|
||||
defaultJavaClassReference,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
@ -255,14 +268,14 @@ class HibernateTypeHelper {
|
|||
void bindHibernateTypeDescriptor(
|
||||
final HibernateTypeDescriptor hibernateTypeDescriptor,
|
||||
final HibernateTypeSource explicitTypeSource,
|
||||
final String defaultJavaTypeName){
|
||||
bindHibernateTypeDescriptor( hibernateTypeDescriptor, explicitTypeSource, defaultJavaTypeName, null);
|
||||
final JavaClassReference defaultJavaClassReference){
|
||||
bindHibernateTypeDescriptor( hibernateTypeDescriptor, explicitTypeSource, defaultJavaClassReference, null);
|
||||
}
|
||||
|
||||
void bindHibernateTypeDescriptor(
|
||||
final HibernateTypeDescriptor hibernateTypeDescriptor,
|
||||
final HibernateTypeSource explicitTypeSource,
|
||||
final String defaultJavaTypeName,
|
||||
final JavaClassReference defaultJavaClassReference,
|
||||
final Type resolvedType) {
|
||||
final String explicitTypeName = explicitTypeSource != null ? explicitTypeSource.getName() : null;
|
||||
final Map<String, String> parameters = explicitTypeSource != null ? explicitTypeSource.getParameters() : null;
|
||||
|
@ -270,7 +283,7 @@ class HibernateTypeHelper {
|
|||
hibernateTypeDescriptor,
|
||||
explicitTypeName,
|
||||
parameters,
|
||||
defaultJavaTypeName,
|
||||
defaultJavaClassReference,
|
||||
resolvedType
|
||||
);
|
||||
}
|
||||
|
@ -340,16 +353,16 @@ class HibernateTypeHelper {
|
|||
void bindAggregatedCompositeAttributeType(
|
||||
final boolean isAttributeIdentifier,
|
||||
final Aggregate composite,
|
||||
final ValueHolder<Class<?>> defaultJavaClassReference,
|
||||
final JavaClassReference defaultJavaClassReference,
|
||||
final CompositeAttributeBinding attributeBinding) {
|
||||
Type resolvedType = typeFactory().component(
|
||||
new ComponentMetamodel( attributeBinding, isAttributeIdentifier, false )
|
||||
);
|
||||
bindHibernateTypeDescriptor(
|
||||
attributeBinding.getHibernateTypeDescriptor(),
|
||||
composite.getClassName(),
|
||||
composite.getClassReference().getName(),
|
||||
null,
|
||||
defaultJavaClassReference == null ? null : defaultJavaClassReference.getValue().getName(),
|
||||
defaultJavaClassReference,
|
||||
resolvedType
|
||||
);
|
||||
}
|
||||
|
@ -357,11 +370,11 @@ class HibernateTypeHelper {
|
|||
void bindBasicCollectionElementType(
|
||||
final BasicPluralAttributeElementBinding elementBinding,
|
||||
final BasicPluralAttributeElementSource elementSource,
|
||||
final String defaultElementJavaTypeName) {
|
||||
final JavaClassReference defaultElementJavaClassReference) {
|
||||
bindHibernateTypeDescriptor(
|
||||
elementBinding.getHibernateTypeDescriptor(),
|
||||
elementSource.getExplicitHibernateTypeSource(),
|
||||
defaultElementJavaTypeName
|
||||
defaultElementJavaClassReference
|
||||
);
|
||||
bindJdbcDataType(
|
||||
elementBinding.getHibernateTypeDescriptor().getResolvedTypeMapping(),
|
||||
|
@ -375,9 +388,12 @@ class HibernateTypeHelper {
|
|||
new ComponentMetamodel( syntheticAttributeBinding, true, false )
|
||||
);
|
||||
final HibernateTypeDescriptor typeDescriptor = syntheticAttributeBinding.getHibernateTypeDescriptor();
|
||||
final String className = syntheticAttribute.getSingularAttributeType().getClassReference() == null ?
|
||||
null :
|
||||
syntheticAttribute.getSingularAttributeType().getClassReference().getName();
|
||||
bindHibernateTypeDescriptor(
|
||||
typeDescriptor,
|
||||
syntheticAttribute.getSingularAttributeType().getClassName(),
|
||||
className,
|
||||
null,
|
||||
null,
|
||||
resolvedType
|
||||
|
@ -387,7 +403,7 @@ class HibernateTypeHelper {
|
|||
final ManyToManyPluralAttributeElementBinding elementBinding,
|
||||
final ManyToManyPluralAttributeElementSource elementSource,
|
||||
final EntityBinding referencedEntityBinding,
|
||||
final String defaultElementJavaTypeName) {
|
||||
final JavaClassReference defaultElementJavaClassReference) {
|
||||
final Type resolvedElementType = typeFactory().manyToOne(
|
||||
referencedEntityBinding.getEntity().getName(),
|
||||
elementSource.getReferencedEntityAttributeName(),
|
||||
|
@ -401,7 +417,7 @@ class HibernateTypeHelper {
|
|||
hibernateTypeDescriptor,
|
||||
referencedEntityBinding.getEntity().getName(),
|
||||
null,
|
||||
defaultElementJavaTypeName,
|
||||
defaultElementJavaClassReference,
|
||||
resolvedElementType
|
||||
);
|
||||
bindJdbcDataType(
|
||||
|
@ -415,7 +431,7 @@ class HibernateTypeHelper {
|
|||
discriminator.getExplicitHibernateTypeDescriptor(),
|
||||
null,
|
||||
null,
|
||||
String.class.getName()
|
||||
bindingContext().makeJavaClassReference( String.class )
|
||||
);
|
||||
bindJdbcDataType( discriminator.getExplicitHibernateTypeDescriptor().getResolvedTypeMapping(), value );
|
||||
}
|
||||
|
@ -425,24 +441,27 @@ class HibernateTypeHelper {
|
|||
final SingularAttributeBinding attributeBinding) {
|
||||
final HibernateTypeDescriptor hibernateTypeDescriptor = attributeBinding
|
||||
.getHibernateTypeDescriptor();
|
||||
final Class<?> attributeJavaType = determineJavaType( attributeSource, attributeBinding);
|
||||
final JavaClassReference attributeJavaClassReference = determineJavaType(
|
||||
attributeSource,
|
||||
attributeBinding.getAttribute().getAttributeContainer()
|
||||
);
|
||||
//try to resolve this attribute's java type first
|
||||
final String defaultJavaTypeName;
|
||||
if ( attributeJavaType != null ) {
|
||||
final JavaClassReference defaultJavaClassReference;
|
||||
if ( attributeJavaClassReference != null ) {
|
||||
attributeBinding.getAttribute().resolveType(
|
||||
makeJavaType(
|
||||
attributeJavaType.getName()
|
||||
makeDomainType(
|
||||
attributeJavaClassReference.getName()
|
||||
)
|
||||
);
|
||||
defaultJavaTypeName = attributeJavaType.getName();
|
||||
defaultJavaClassReference = attributeJavaClassReference;
|
||||
} else {
|
||||
defaultJavaTypeName = null;
|
||||
defaultJavaClassReference = null;
|
||||
}
|
||||
//do our best to full fill hibernateTypeDescriptor
|
||||
bindHibernateTypeDescriptor(
|
||||
hibernateTypeDescriptor,
|
||||
attributeSource.getTypeInformation(),
|
||||
defaultJavaTypeName
|
||||
defaultJavaClassReference
|
||||
);
|
||||
|
||||
processSingularAttributeTypeInformation(
|
||||
|
@ -472,7 +491,7 @@ class HibernateTypeHelper {
|
|||
return typeFactory().array(
|
||||
role,
|
||||
propertyRef,
|
||||
pluralAttributeSource.getElementClassReference().getValue()
|
||||
pluralAttributeSource.getElementJavaClassReference().getResolvedClass()
|
||||
);
|
||||
case MAP:
|
||||
if ( pluralAttributeBinding.isSorted() ) {
|
||||
|
@ -518,7 +537,7 @@ class HibernateTypeHelper {
|
|||
final SingularAttribute singularAttribute) {
|
||||
if ( singularAttribute.getSingularAttributeType() != null ) {
|
||||
return getHeuristicType(
|
||||
singularAttribute.getSingularAttributeType().getClassName(),
|
||||
singularAttribute.getSingularAttributeType().getClassReference().getName(),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
@ -593,18 +612,20 @@ class HibernateTypeHelper {
|
|||
final HibernateTypeDescriptor hibernateTypeDescriptor,
|
||||
final String explicitTypeName,
|
||||
final Map<String, String> explictTypeParameters,
|
||||
final String defaultJavaTypeName) {
|
||||
final JavaClassReference defaultJavaClassReference) {
|
||||
if ( explicitTypeName == null ) {
|
||||
if ( defaultJavaTypeName != null && hibernateTypeDescriptor.getJavaTypeName() != null ) {
|
||||
throw bindingContext().makeMappingException(
|
||||
String.format(
|
||||
"Attempt to re-initialize (non-explicit) Java type name; current=%s new=%s",
|
||||
hibernateTypeDescriptor.getJavaTypeName(),
|
||||
defaultJavaTypeName
|
||||
)
|
||||
);
|
||||
if ( defaultJavaClassReference != null ) {
|
||||
if ( hibernateTypeDescriptor.getClassReference() != null ) {
|
||||
throw bindingContext().makeMappingException(
|
||||
String.format(
|
||||
"Attempt to re-initialize (non-explicit) Java type name; current=%s new=%s",
|
||||
hibernateTypeDescriptor.getClassReference(),
|
||||
defaultJavaClassReference
|
||||
)
|
||||
);
|
||||
}
|
||||
hibernateTypeDescriptor.setClassReference( defaultJavaClassReference );
|
||||
}
|
||||
hibernateTypeDescriptor.setJavaTypeName( defaultJavaTypeName );
|
||||
}
|
||||
else {
|
||||
// Check if user-specified name is of a User-Defined Type (UDT)
|
||||
|
@ -643,16 +664,18 @@ class HibernateTypeHelper {
|
|||
if ( hibernateTypeDescriptor.getResolvedTypeMapping() == null ) {
|
||||
hibernateTypeDescriptor.setResolvedTypeMapping( resolvedHibernateType );
|
||||
}
|
||||
if ( hibernateTypeDescriptor.getJavaTypeName() == null ) {
|
||||
if ( hibernateTypeDescriptor.getClassReference() == null ) {
|
||||
// try to get Java type name from attribute because it may not be available from
|
||||
// resolvedHibernateType until after persisters are available.
|
||||
if ( attributeBinding.getAttribute().isTypeResolved() ) {
|
||||
hibernateTypeDescriptor.setJavaTypeName(
|
||||
attributeBinding.getAttribute().getSingularAttributeType().getClassName()
|
||||
hibernateTypeDescriptor.setClassReference(
|
||||
attributeBinding.getAttribute().getSingularAttributeType().getClassReference()
|
||||
);
|
||||
}
|
||||
else {
|
||||
hibernateTypeDescriptor.setJavaTypeName( resolvedHibernateType.getReturnedClass().getName() );
|
||||
hibernateTypeDescriptor.setClassReference( bindingContext().makeJavaClassReference(
|
||||
resolvedHibernateType.getReturnedClass()
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -682,8 +705,8 @@ class HibernateTypeHelper {
|
|||
final Type resolvedHibernateType) {
|
||||
final HibernateTypeDescriptor hibernateTypeDescriptor = attributeBinding.getHibernateTypeDescriptor();
|
||||
final SingularAttribute singularAttribute = attributeBinding.getAttribute();
|
||||
if ( !singularAttribute.isTypeResolved() && hibernateTypeDescriptor.getJavaTypeName() != null ) {
|
||||
singularAttribute.resolveType( makeJavaType( hibernateTypeDescriptor.getJavaTypeName() ) );
|
||||
if ( !singularAttribute.isTypeResolved() && hibernateTypeDescriptor.getClassReference() != null ) {
|
||||
singularAttribute.resolveType( makeDomainType( hibernateTypeDescriptor.getClassReference().getName() ) );
|
||||
}
|
||||
bindJdbcDataType( resolvedHibernateType, attributeBinding.getRelationalValueBindings() );
|
||||
}
|
||||
|
@ -696,8 +719,8 @@ class HibernateTypeHelper {
|
|||
final HibernateTypeDescriptor hibernateTypeDescriptor = attributeBinding.getHibernateTypeDescriptor();
|
||||
|
||||
final SingularAttribute singularAttribute = attributeBinding.getAttribute();
|
||||
if ( !singularAttribute.isTypeResolved() && hibernateTypeDescriptor.getJavaTypeName() != null ) {
|
||||
singularAttribute.resolveType( makeJavaType( hibernateTypeDescriptor.getJavaTypeName() ) );
|
||||
if ( !singularAttribute.isTypeResolved() && hibernateTypeDescriptor.getClassReference() != null ) {
|
||||
singularAttribute.resolveType( makeDomainType( hibernateTypeDescriptor.getClassReference().getName() ) );
|
||||
}
|
||||
|
||||
Iterator<AttributeSource> subAttributeSourceIterator = attributeSource.attributeSources().iterator();
|
||||
|
@ -726,53 +749,43 @@ class HibernateTypeHelper {
|
|||
return bindingContext().getMetadataImplementor();
|
||||
}
|
||||
|
||||
private org.hibernate.metamodel.spi.domain.Type makeJavaType(String name) {
|
||||
return bindingContext().makeJavaType( name );
|
||||
private org.hibernate.metamodel.spi.domain.Type makeDomainType(String name) {
|
||||
return bindingContext().makeDomainType( name );
|
||||
}
|
||||
|
||||
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private static methods
|
||||
private static String determineTypeName(
|
||||
final HibernateTypeDescriptor hibernateTypeDescriptor) {
|
||||
return hibernateTypeDescriptor.getExplicitTypeName() != null
|
||||
? hibernateTypeDescriptor.getExplicitTypeName()
|
||||
: hibernateTypeDescriptor.getJavaTypeName();
|
||||
: hibernateTypeDescriptor.getClassReference().getName();
|
||||
}
|
||||
|
||||
|
||||
private static Class<?> determineJavaType(final SingularAttributeSource attributeSource,
|
||||
final SingularAttributeBinding attributeBinding) {
|
||||
Class clazz = attributeSource.getTypeInformation().getJavaType();
|
||||
if ( clazz != null ) {
|
||||
return clazz;
|
||||
public JavaClassReference determineJavaType(
|
||||
final AttributeSource attributeSource,
|
||||
final AttributeContainer attributeContainer) {
|
||||
if ( attributeSource.getTypeInformation() != null && attributeSource.getTypeInformation().getJavaType() != null ) {
|
||||
return bindingContext().makeJavaClassReference( attributeSource.getTypeInformation().getJavaType() );
|
||||
}
|
||||
final SingularAttribute attribute = attributeBinding.getAttribute();
|
||||
try {
|
||||
final EntityMode entityMode = attributeBinding.getContainer()
|
||||
.seekEntityBinding()
|
||||
.getHierarchyDetails()
|
||||
.getEntityMode();
|
||||
if ( entityMode != EntityMode.POJO ) {
|
||||
return null;
|
||||
}
|
||||
final Class<?> ownerClass = attribute.getAttributeContainer().getClassReference();
|
||||
return ReflectHelper.reflectedPropertyClass( ownerClass, attribute.getName() );
|
||||
else if ( attributeContainer.getClassReference() == null ) {
|
||||
return null;
|
||||
}
|
||||
catch ( Exception ignore ) {
|
||||
log.debugf(
|
||||
"Unable to locate attribute [%s] on class [%s]",
|
||||
attribute.getName(),
|
||||
attribute.getAttributeContainer().getClassName()
|
||||
else {
|
||||
return bindingContext().makeJavaPropertyClassReference(
|
||||
attributeContainer.getClassReference(),
|
||||
attributeSource.getName()
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static ReflectedCollectionJavaTypes determineJavaType(PluralAttribute attribute) {
|
||||
private static ReflectedCollectionJavaTypes determineReflectedCollectionJavaTypes(PluralAttribute attribute) {
|
||||
if ( attribute.getAttributeContainer().getClassReference() == null ) {
|
||||
return null; // EARLY RETURN
|
||||
}
|
||||
final Class<?> ownerClass = attribute.getAttributeContainer().getClassReference().getResolvedClass();
|
||||
try {
|
||||
final Class<?> ownerClass = attribute.getAttributeContainer().getClassReference();
|
||||
PluralAttributeJavaTypeDeterminerDelegate delegate = new PluralAttributeJavaTypeDeterminerDelegate(
|
||||
ownerClass,
|
||||
attribute.getName()
|
||||
|
@ -784,7 +797,7 @@ class HibernateTypeHelper {
|
|||
log.debugf(
|
||||
"Unable to locate attribute [%s] on class [%s]",
|
||||
attribute.getName(),
|
||||
attribute.getAttributeContainer().getClassName()
|
||||
attribute.getAttributeContainer().getClassReference().getName()
|
||||
);
|
||||
}
|
||||
return null;
|
||||
|
@ -823,7 +836,7 @@ class HibernateTypeHelper {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see HibernateTypeHelper#determineJavaType(PluralAttribute)
|
||||
* @see HibernateTypeHelper#determineReflectedCollectionJavaTypes(PluralAttribute)
|
||||
*/
|
||||
private static class PluralAttributeJavaTypeDeterminerDelegate implements BeanInfoHelper.BeanInfoDelegate {
|
||||
private final Class<?> ownerClass;
|
||||
|
|
|
@ -55,8 +55,10 @@ import org.hibernate.engine.spi.SyntheticAttributeHelper;
|
|||
import org.hibernate.id.factory.IdentifierGeneratorFactory;
|
||||
import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.xml.spi.BindResult;
|
||||
import org.hibernate.metamodel.MetadataSourceProcessingOrder;
|
||||
import org.hibernate.metamodel.MetadataSources;
|
||||
import org.hibernate.metamodel.SessionFactoryBuilder;
|
||||
|
@ -105,7 +107,6 @@ import org.hibernate.type.TypeFactory;
|
|||
import org.hibernate.type.TypeResolver;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
import org.hibernate.usertype.UserType;
|
||||
import org.hibernate.xml.spi.BindResult;
|
||||
|
||||
import org.jboss.jandex.IndexView;
|
||||
import org.jboss.logging.Logger;
|
||||
|
@ -707,39 +708,62 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Type makeJavaType(String className) {
|
||||
public Type makeDomainType(String className) {
|
||||
// todo : have this perform some analysis of the incoming type name to determine appropriate return
|
||||
return new BasicType( className, makeClassReference( className ) );
|
||||
return new BasicType( className, makeJavaClassReference( className ) );
|
||||
}
|
||||
|
||||
// TODO: ClassLoaderService.classForName( className ) does not work for primitives, so add mapping
|
||||
// from primitive class names -> class.
|
||||
private static final Map<String,Class<?>> primitiveClassesByName = new HashMap<String,Class<?>>();
|
||||
static {
|
||||
primitiveClassesByName.put("int", Integer.TYPE );
|
||||
primitiveClassesByName.put( "long", Long.TYPE );
|
||||
primitiveClassesByName.put( "double", Double.TYPE );
|
||||
primitiveClassesByName.put( "float", Float.TYPE );
|
||||
primitiveClassesByName.put( "bool", Boolean.TYPE );
|
||||
primitiveClassesByName.put( "char", Character.TYPE );
|
||||
primitiveClassesByName.put( "byte", Byte.TYPE );
|
||||
primitiveClassesByName.put( "void", Void.TYPE );
|
||||
primitiveClassesByName.put( "short", Short.TYPE );
|
||||
private Map<String, JavaClassReference> nameToJavaTypeMap = new HashMap<String, JavaClassReference>();
|
||||
|
||||
@Override
|
||||
public JavaClassReference makeJavaClassReference(final String className) {
|
||||
if ( className == null ) {
|
||||
throw new IllegalArgumentException( "className must be non-null." );
|
||||
}
|
||||
JavaClassReference javaClassReference = nameToJavaTypeMap.get( className );
|
||||
if ( javaClassReference == null ) {
|
||||
javaClassReference = new JavaClassReference( className, classLoaderService );
|
||||
nameToJavaTypeMap.put( className, javaClassReference );
|
||||
}
|
||||
return javaClassReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueHolder<Class<?>> makeClassReference(final String className) {
|
||||
return new ValueHolder<Class<?>>(
|
||||
new ValueHolder.DeferredInitializer<Class<?>>() {
|
||||
@Override
|
||||
public Class<?> initialize() {
|
||||
Class<?> primitiveClass = primitiveClassesByName.get( className );
|
||||
return primitiveClass == null ?
|
||||
classLoaderService.classForName( className ) :
|
||||
primitiveClass;
|
||||
}
|
||||
}
|
||||
);
|
||||
public JavaClassReference makeJavaClassReference(Class<?> clazz) {
|
||||
if ( clazz == null ) {
|
||||
throw new IllegalArgumentException( "clazz must be non-null." );
|
||||
}
|
||||
JavaClassReference javaClassReference = nameToJavaTypeMap.get( clazz.getName() );
|
||||
if ( javaClassReference == null ) {
|
||||
javaClassReference = new JavaClassReference( clazz );
|
||||
nameToJavaTypeMap.put( clazz.getName(), javaClassReference );
|
||||
}
|
||||
return javaClassReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaClassReference makeJavaPropertyClassReference(
|
||||
JavaClassReference propertyContainerClassReference,
|
||||
String propertyName) {
|
||||
if ( propertyContainerClassReference == null || propertyName == null ) {
|
||||
throw new IllegalArgumentException( "propertyContainerClassReference and propertyName must be non-null." );
|
||||
}
|
||||
try {
|
||||
return makeJavaClassReference(
|
||||
ReflectHelper.reflectedPropertyClass(
|
||||
propertyContainerClassReference.getResolvedClass(),
|
||||
propertyName
|
||||
)
|
||||
);
|
||||
}
|
||||
catch ( Exception ignore ) {
|
||||
LOG.debugf(
|
||||
"Unable to locate attribute [%s] on class [%s]",
|
||||
propertyName,
|
||||
propertyContainerClassReference.getName()
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -784,7 +808,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
}
|
||||
entityBindingMap.put( entityName, entityBinding );
|
||||
final boolean isPOJO = entityBinding.getHierarchyDetails().getEntityMode() == EntityMode.POJO;
|
||||
final String className = isPOJO ? entityBinding.getEntity().getClassName() : null;
|
||||
final String className = isPOJO ? entityBinding.getEntity().getClassReference().getName() : null;
|
||||
if ( isPOJO && StringHelper.isEmpty( className ) ) {
|
||||
throw new MappingException( "Entity[" + entityName + "] is mapped as pojo but don't have a class name" );
|
||||
}
|
||||
|
|
|
@ -23,14 +23,11 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.internal.source.annotations;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.metamodel.spi.MetadataImplementor;
|
||||
import org.hibernate.metamodel.spi.binding.IdentifierGeneratorDefinition;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.metamodel.spi.domain.Type;
|
||||
import org.hibernate.metamodel.spi.source.MappingDefaults;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
@ -117,21 +114,26 @@ public class AnnotationBindingContextImpl implements AnnotationBindingContext {
|
|||
return classLoaderService.classForName( name );
|
||||
}
|
||||
|
||||
private Map<String, Type> nameToJavaTypeMap = new HashMap<String, Type>();
|
||||
|
||||
@Override
|
||||
public Type makeJavaType(String className) {
|
||||
Type javaType = nameToJavaTypeMap.get( className );
|
||||
if ( javaType == null ) {
|
||||
javaType = metadata.makeJavaType( className );
|
||||
nameToJavaTypeMap.put( className, javaType );
|
||||
}
|
||||
return javaType;
|
||||
public Type makeDomainType(String className) {
|
||||
return metadata.makeDomainType( className );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueHolder<Class<?>> makeClassReference(String className) {
|
||||
return new ValueHolder<Class<?>>( locateClassByName( className ) );
|
||||
public JavaClassReference makeJavaClassReference(String className) {
|
||||
return metadata.makeJavaClassReference( className );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaClassReference makeJavaClassReference(Class<?> clazz) {
|
||||
return metadata.makeJavaClassReference( clazz );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaClassReference makeJavaPropertyClassReference(
|
||||
JavaClassReference propertyContainerClassReference,
|
||||
String propertyName) {
|
||||
return metadata.makeJavaPropertyClassReference( propertyContainerClassReference, propertyName );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,12 +29,12 @@ import java.util.Map;
|
|||
import javax.persistence.AccessType;
|
||||
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.internal.source.annotations.attribute.AssociationOverride;
|
||||
import org.hibernate.metamodel.internal.source.annotations.attribute.AttributeOverride;
|
||||
import org.hibernate.metamodel.internal.source.annotations.entity.EmbeddableClass;
|
||||
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.metamodel.spi.source.AttributeSource;
|
||||
import org.hibernate.metamodel.spi.source.ComponentAttributeSource;
|
||||
import org.hibernate.metamodel.spi.source.HibernateTypeSource;
|
||||
|
@ -51,7 +51,7 @@ import org.hibernate.metamodel.spi.source.RelationalValueSource;
|
|||
*/
|
||||
public class ComponentAttributeSourceImpl implements ComponentAttributeSource, AnnotationAttributeSource {
|
||||
private final EmbeddableClass embeddableClass;
|
||||
private final ValueHolder<Class<?>> classReference;
|
||||
private final JavaClassReference javaClassReference;
|
||||
private final String path;
|
||||
private final AccessType classAccessType;
|
||||
private Map<String, AttributeOverride> attributeOverrideMap;
|
||||
|
@ -61,7 +61,7 @@ public class ComponentAttributeSourceImpl implements ComponentAttributeSource, A
|
|||
final String parentPath,
|
||||
final AccessType classAccessType) {
|
||||
this.embeddableClass = embeddableClass;
|
||||
this.classReference = new ValueHolder<Class<?>>( embeddableClass.getConfiguredClass() );
|
||||
this.javaClassReference = getLocalBindingContext().makeJavaClassReference( embeddableClass.getConfiguredClass() );
|
||||
this.path = StringHelper.isEmpty( parentPath ) ? embeddableClass.getEmbeddedAttributeName() : parentPath + "." + embeddableClass.getEmbeddedAttributeName();
|
||||
this.classAccessType = classAccessType;
|
||||
}
|
||||
|
@ -92,13 +92,8 @@ public class ComponentAttributeSourceImpl implements ComponentAttributeSource, A
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return embeddableClass.getConfiguredClass().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueHolder<Class<?>> getClassReference() {
|
||||
return classReference;
|
||||
public JavaClassReference getClassReference() {
|
||||
return javaClassReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.internal.source.annotations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -28,7 +27,6 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.metamodel.internal.source.annotations.attribute.AssociationAttribute;
|
||||
import org.hibernate.metamodel.internal.source.annotations.attribute.AssociationOverride;
|
||||
import org.hibernate.metamodel.internal.source.annotations.attribute.AttributeOverride;
|
||||
|
@ -36,6 +34,7 @@ import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssoc
|
|||
import org.hibernate.metamodel.internal.source.annotations.entity.ConfiguredClass;
|
||||
import org.hibernate.metamodel.internal.source.annotations.entity.EmbeddableClass;
|
||||
import org.hibernate.metamodel.spi.binding.CascadeType;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.metamodel.spi.source.AttributeSource;
|
||||
import org.hibernate.metamodel.spi.source.CompositePluralAttributeElementSource;
|
||||
import org.hibernate.metamodel.spi.source.LocalBindingContext;
|
||||
|
@ -129,13 +128,8 @@ public class CompositePluralAttributeElementSourceImpl implements CompositePlura
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return associationAttribute.getReferencedEntityType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueHolder<Class<?>> getClassReference() {
|
||||
return getLocalBindingContext().makeClassReference( getClassName() );
|
||||
public JavaClassReference getClassReference() {
|
||||
return getLocalBindingContext().makeJavaClassReference( associationAttribute.getReferencedEntityType() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,10 +27,10 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.metamodel.internal.Binder;
|
||||
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
|
||||
import org.hibernate.metamodel.spi.binding.PluralAttributeIndexBinding;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.metamodel.spi.source.AttributeSource;
|
||||
import org.hibernate.metamodel.spi.source.CompositePluralAttributeIndexSource;
|
||||
import org.hibernate.metamodel.spi.source.LocalBindingContext;
|
||||
|
@ -87,13 +87,8 @@ public class CompositePluralAttributeIndexSourceImpl extends AbstractPluralAttri
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return pluralAssociationAttribute().getIndexType().getName();
|
||||
}
|
||||
|
||||
public ValueHolder<Class<?>> getClassReference() {
|
||||
return getLocalBindingContext().makeClassReference( getClassName() );
|
||||
public JavaClassReference getClassReference() {
|
||||
return getLocalBindingContext().makeJavaClassReference( pluralAssociationAttribute().getIndexType().getName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.hibernate.AssertionFailure;
|
|||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.metamodel.internal.source.annotations.attribute.AssociationOverride;
|
||||
import org.hibernate.metamodel.internal.source.annotations.attribute.AttributeOverride;
|
||||
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
|
||||
|
@ -41,6 +40,7 @@ import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotName
|
|||
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.metamodel.spi.binding.Caching;
|
||||
import org.hibernate.metamodel.spi.binding.CustomSQL;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.metamodel.spi.source.AssociationSource;
|
||||
import org.hibernate.metamodel.spi.source.AttributeSource;
|
||||
import org.hibernate.metamodel.spi.source.AttributeSourceResolutionContext;
|
||||
|
@ -174,11 +174,11 @@ public class PluralAttributeSourceImpl implements AnnotationAttributeSource, Plu
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueHolder<Class<?>> getElementClassReference() {
|
||||
public JavaClassReference getElementJavaClassReference() {
|
||||
// needed for arrays
|
||||
Class<?> attributeType = associationAttribute.getAttributeType();
|
||||
if ( attributeType.isArray() ) {
|
||||
return new ValueHolder<Class<?>>( attributeType.getComponentType() );
|
||||
return entityClass.getLocalBindingContext().makeJavaClassReference( attributeType.getComponentType() );
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
package org.hibernate.metamodel.internal.source.annotations.entity;
|
||||
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.xml.spi.Origin;
|
||||
import org.hibernate.xml.spi.SourceType;
|
||||
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext;
|
||||
|
@ -96,8 +96,8 @@ public class EntityBindingContext implements LocalBindingContext, AnnotationBind
|
|||
}
|
||||
|
||||
@Override
|
||||
public Type makeJavaType(String className) {
|
||||
return contextDelegate.makeJavaType( className );
|
||||
public Type makeDomainType(String className) {
|
||||
return contextDelegate.makeDomainType( className );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -106,8 +106,20 @@ public class EntityBindingContext implements LocalBindingContext, AnnotationBind
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueHolder<Class<?>> makeClassReference(String className) {
|
||||
return contextDelegate.makeClassReference( className );
|
||||
public JavaClassReference makeJavaClassReference(String className) {
|
||||
return contextDelegate.makeJavaClassReference( className );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaClassReference makeJavaClassReference(Class<?> clazz) {
|
||||
return contextDelegate.makeJavaClassReference( clazz );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaClassReference makeJavaPropertyClassReference(
|
||||
JavaClassReference propertyContainerClassReference,
|
||||
String propertyName) {
|
||||
return contextDelegate.makeJavaPropertyClassReference( propertyContainerClassReference, propertyName );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,7 +26,6 @@ package org.hibernate.metamodel.internal.source.hbm;
|
|||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.NotYetImplementedException;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.metamodel.source.internal.jaxb.hbm.ComponentSourceElement;
|
||||
import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbAnyElement;
|
||||
import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbArrayElement;
|
||||
|
@ -43,6 +42,7 @@ import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbPrimitiveArrayElemen
|
|||
import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbPropertyElement;
|
||||
import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbSetElement;
|
||||
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.metamodel.spi.source.AttributeSource;
|
||||
import org.hibernate.metamodel.spi.source.AttributeSourceContainer;
|
||||
import org.hibernate.metamodel.spi.source.ComponentAttributeSource;
|
||||
|
@ -59,7 +59,7 @@ public abstract class AbstractComponentAttributeSourceImpl extends AbstractHbmSo
|
|||
private final AttributeSourceContainer parentContainer;
|
||||
private final List<AttributeSource> subAttributeSources;
|
||||
private final SingularAttributeBinding.NaturalIdMutability naturalIdMutability;
|
||||
private final ValueHolder<Class<?>> componentClassReference;
|
||||
private final JavaClassReference javaClassReference;
|
||||
private final String logicalTableName;
|
||||
private final String path;
|
||||
|
||||
|
@ -73,7 +73,7 @@ public abstract class AbstractComponentAttributeSourceImpl extends AbstractHbmSo
|
|||
this.componentSourceElement = componentSourceElement;
|
||||
this.parentContainer = parentContainer;
|
||||
this.naturalIdMutability = naturalIdMutability;
|
||||
this.componentClassReference = makeClassReference( componentSourceElement.getClazz() );
|
||||
this.javaClassReference = makeJavaClassReference( componentSourceElement.getClazz() );
|
||||
this.logicalTableName = logicalTableName;
|
||||
this.path = parentContainer.getPath() + '.' + componentSourceElement.getName();
|
||||
|
||||
|
@ -187,13 +187,8 @@ public abstract class AbstractComponentAttributeSourceImpl extends AbstractHbmSo
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return componentSourceElement.getClazz();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueHolder<Class<?>> getClassReference() {
|
||||
return componentClassReference;
|
||||
public JavaClassReference getClassReference() {
|
||||
return javaClassReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.internal.source.hbm;
|
||||
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.xml.spi.BindResult;
|
||||
import org.hibernate.xml.spi.Origin;
|
||||
import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbHibernateMapping;
|
||||
|
@ -59,8 +59,10 @@ public abstract class AbstractHbmSourceNode {
|
|||
return sourceMappingDocument().getJaxbRoot();
|
||||
}
|
||||
|
||||
protected ValueHolder<Class<?>> makeClassReference(String className) {
|
||||
return bindingContext().makeClassReference( bindingContext().qualifyClassName( className ) );
|
||||
protected JavaClassReference makeJavaClassReference(String className) {
|
||||
return className == null ?
|
||||
null :
|
||||
bindingContext().makeJavaClassReference( bindingContext().qualifyClassName( className ) );
|
||||
}
|
||||
|
||||
protected MappingException makeMappingException(String message) {
|
||||
|
|
|
@ -31,11 +31,11 @@ import org.hibernate.cfg.NotYetImplementedException;
|
|||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbFilterElement;
|
||||
import org.hibernate.metamodel.source.internal.jaxb.hbm.PluralAttributeElement;
|
||||
import org.hibernate.metamodel.spi.binding.Caching;
|
||||
import org.hibernate.metamodel.spi.binding.CustomSQL;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.metamodel.spi.source.AttributeSourceContainer;
|
||||
import org.hibernate.metamodel.spi.source.AttributeSourceResolutionContext;
|
||||
import org.hibernate.metamodel.spi.source.HibernateTypeSource;
|
||||
|
@ -63,7 +63,7 @@ public abstract class AbstractPluralAttributeSourceImpl
|
|||
private final PluralAttributeElementSource elementSource;
|
||||
private final Caching caching;
|
||||
private final FilterSource[] filterSources;
|
||||
private ValueHolder<Class<?>> elementClassReference;
|
||||
private JavaClassReference elementJavaClassReference;
|
||||
|
||||
protected AbstractPluralAttributeSourceImpl(
|
||||
MappingDocument sourceMappingDocument,
|
||||
|
@ -130,8 +130,10 @@ public abstract class AbstractPluralAttributeSourceImpl
|
|||
);
|
||||
}
|
||||
else if ( pluralAttributeElement.getCompositeElement() != null ) {
|
||||
elementClassReference = makeClassReference(pluralAttributeElement
|
||||
.getCompositeElement().getClazz());
|
||||
elementJavaClassReference = makeJavaClassReference(
|
||||
pluralAttributeElement
|
||||
.getCompositeElement().getClazz()
|
||||
);
|
||||
return new CompositePluralAttributeElementSourceImpl(
|
||||
sourceMappingDocument(),
|
||||
pluralAttributeElement.getCompositeElement(),
|
||||
|
@ -139,8 +141,10 @@ public abstract class AbstractPluralAttributeSourceImpl
|
|||
);
|
||||
}
|
||||
else if ( pluralAttributeElement.getOneToMany() != null ) {
|
||||
elementClassReference = makeClassReference(pluralAttributeElement
|
||||
.getOneToMany().getClazz());
|
||||
elementJavaClassReference = makeJavaClassReference(
|
||||
pluralAttributeElement
|
||||
.getOneToMany().getClazz()
|
||||
);
|
||||
return new OneToManyPluralAttributeElementSourceImpl(
|
||||
sourceMappingDocument(),
|
||||
this,
|
||||
|
@ -149,8 +153,10 @@ public abstract class AbstractPluralAttributeSourceImpl
|
|||
);
|
||||
}
|
||||
else if ( pluralAttributeElement.getManyToMany() != null ) {
|
||||
elementClassReference = makeClassReference(pluralAttributeElement
|
||||
.getManyToMany().getClazz());
|
||||
elementJavaClassReference = makeJavaClassReference(
|
||||
pluralAttributeElement
|
||||
.getManyToMany().getClazz()
|
||||
);
|
||||
return new ManyToManyPluralAttributeElementSourceImpl(
|
||||
sourceMappingDocument(),
|
||||
this,
|
||||
|
@ -223,8 +229,8 @@ public abstract class AbstractPluralAttributeSourceImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueHolder<Class<?>> getElementClassReference() {
|
||||
return elementClassReference;
|
||||
public JavaClassReference getElementJavaClassReference() {
|
||||
return elementJavaClassReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.hibernate.EntityMode;
|
|||
import org.hibernate.cfg.NotYetImplementedException;
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbAnyElement;
|
||||
import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbCompositeElementElement;
|
||||
import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbManyToOneElement;
|
||||
|
@ -39,6 +38,7 @@ import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbNestedCompositeEleme
|
|||
import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbPropertyElement;
|
||||
import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbTuplizerElement;
|
||||
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.metamodel.spi.source.AttributeSource;
|
||||
import org.hibernate.metamodel.spi.source.CompositePluralAttributeElementSource;
|
||||
import org.hibernate.metamodel.spi.source.LocalBindingContext;
|
||||
|
@ -73,13 +73,9 @@ public class CompositePluralAttributeElementSourceImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return bindingContext().qualifyClassName( compositeElement.getClazz() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueHolder<Class<?>> getClassReference() {
|
||||
return bindingContext().makeClassReference( getClassName() );
|
||||
public JavaClassReference getClassReference() {
|
||||
final String className = bindingContext().qualifyClassName( compositeElement.getClazz() );
|
||||
return bindingContext().makeJavaClassReference( className );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,7 +26,6 @@ package org.hibernate.metamodel.internal.source.hbm;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbCompositeIndexElement;
|
||||
import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbCompositeMapKeyElement;
|
||||
import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbKeyManyToOneElement;
|
||||
|
@ -34,6 +33,7 @@ import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbKeyPropertyElement;
|
|||
import org.hibernate.metamodel.internal.Binder;
|
||||
import org.hibernate.metamodel.spi.binding.PluralAttributeIndexBinding;
|
||||
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.metamodel.spi.source.AttributeSource;
|
||||
import org.hibernate.metamodel.spi.source.CompositePluralAttributeIndexSource;
|
||||
import org.hibernate.metamodel.spi.source.HibernateTypeSource;
|
||||
|
@ -107,13 +107,8 @@ public class CompositePluralAttributeIndexSourceImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueHolder<Class<?>> getClassReference() {
|
||||
return bindingContext().makeClassReference( className );
|
||||
public JavaClassReference getClassReference() {
|
||||
return bindingContext().makeJavaClassReference( className );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,8 +26,8 @@ package org.hibernate.metamodel.internal.source.hbm;
|
|||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.xml.spi.BindResult;
|
||||
import org.hibernate.xml.spi.Origin;
|
||||
import org.hibernate.metamodel.source.internal.jaxb.hbm.EntityElement;
|
||||
|
@ -129,13 +129,25 @@ public class MappingDocument {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Type makeJavaType(String className) {
|
||||
return metadata.makeJavaType( className );
|
||||
public Type makeDomainType(String className) {
|
||||
return metadata.makeDomainType( className );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueHolder<Class<?>> makeClassReference(String className) {
|
||||
return metadata.makeClassReference( className );
|
||||
public JavaClassReference makeJavaClassReference(String className) {
|
||||
return metadata.makeJavaClassReference( className );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaClassReference makeJavaClassReference(Class<?> clazz) {
|
||||
return metadata.makeJavaClassReference( clazz );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaClassReference makeJavaPropertyClassReference(
|
||||
JavaClassReference propertyContainerClassReference,
|
||||
String propertyName) {
|
||||
return metadata.makeJavaPropertyClassReference( propertyContainerClassReference, propertyName );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.metamodel.spi.domain.PluralAttribute;
|
||||
import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
||||
import org.hibernate.metamodel.spi.relational.TableSpecification;
|
||||
|
@ -77,7 +78,7 @@ public abstract class AbstractAttributeBindingContainer implements AttributeBind
|
|||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getClassReference() {
|
||||
public JavaClassReference getClassReference() {
|
||||
return getAttributeContainer().getClassReference();
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.List;
|
|||
|
||||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.spi.domain.AttributeContainer;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.metamodel.spi.domain.PluralAttribute;
|
||||
import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
||||
import org.hibernate.metamodel.spi.relational.TableSpecification;
|
||||
|
@ -104,12 +105,12 @@ public interface AttributeBindingContainer {
|
|||
EntityBinding seekEntityBinding();
|
||||
|
||||
/**
|
||||
* Obtain the {@link Class} reference for this attribute container. Generally this is used to perform reflection
|
||||
* Obtain the {@link JavaClassReference} for this attribute container. Generally this is used to perform reflection
|
||||
* on the attributes.
|
||||
*
|
||||
* @return The {@link Class} reference
|
||||
* @return The {@link JavaClassReference}
|
||||
*/
|
||||
Class<?> getClassReference();
|
||||
JavaClassReference getClassReference();
|
||||
|
||||
/**
|
||||
* Obtain the meta-attribute context for this container.
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.hibernate.engine.spi.CascadeStyles;
|
|||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.spi.domain.AttributeContainer;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.metamodel.spi.domain.PluralAttribute;
|
||||
import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
||||
import org.hibernate.metamodel.spi.relational.TableSpecification;
|
||||
|
@ -357,7 +358,7 @@ public class CompositeAttributeBinding
|
|||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getClassReference() {
|
||||
public JavaClassReference getClassReference() {
|
||||
return compositeAttributeBindingContainer.getClassReference();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,10 +35,10 @@ import org.hibernate.EntityMode;
|
|||
import org.hibernate.MappingException;
|
||||
import org.hibernate.internal.FilterConfiguration;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||
import org.hibernate.metamodel.spi.domain.AttributeContainer;
|
||||
import org.hibernate.metamodel.spi.domain.Entity;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
||||
import org.hibernate.metamodel.spi.relational.Identifier;
|
||||
import org.hibernate.metamodel.spi.relational.TableSpecification;
|
||||
|
@ -46,7 +46,6 @@ import org.hibernate.metamodel.spi.relational.Value;
|
|||
import org.hibernate.metamodel.spi.source.JpaCallbackSource;
|
||||
import org.hibernate.metamodel.spi.source.MetaAttributeContext;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.property.PropertyAccessorFactory;
|
||||
import org.hibernate.tuple.entity.EntityTuplizer;
|
||||
|
||||
/**
|
||||
|
@ -70,7 +69,7 @@ public class EntityBinding extends AbstractAttributeBindingContainer implements
|
|||
private String primaryTableName;
|
||||
private Map<Identifier, SecondaryTable> secondaryTables = new LinkedHashMap<Identifier, SecondaryTable>();
|
||||
|
||||
private ValueHolder<Class<?>> proxyInterfaceType;
|
||||
private JavaClassReference proxyInterfaceType;
|
||||
|
||||
private String entityName;
|
||||
private String jpaEntityName;
|
||||
|
@ -358,11 +357,11 @@ public class EntityBinding extends AbstractAttributeBindingContainer implements
|
|||
this.lazy = lazy;
|
||||
}
|
||||
|
||||
public ValueHolder<Class<?>> getProxyInterfaceType() {
|
||||
public JavaClassReference getProxyInterfaceType() {
|
||||
return proxyInterfaceType;
|
||||
}
|
||||
|
||||
public void setProxyInterfaceType(ValueHolder<Class<?>> proxyInterfaceType) {
|
||||
public void setProxyInterfaceType(JavaClassReference proxyInterfaceType) {
|
||||
this.proxyInterfaceType = proxyInterfaceType;
|
||||
}
|
||||
|
||||
|
|
|
@ -449,8 +449,6 @@ public class EntityIdentifier {
|
|||
factory, properties
|
||||
);
|
||||
}
|
||||
final Class entityClass = entityBinding.getEntity().getClassReference();
|
||||
final Class attributeDeclarer; // what class is the declarer of the composite pk attributes
|
||||
// IMPL NOTE : See the javadoc discussion on CompositeNestedGeneratedValueGenerator wrt the
|
||||
// various scenarios for which we need to account here
|
||||
// we have the "@EmbeddedId" / <composite-id name="idName"/> case
|
||||
|
@ -564,9 +562,6 @@ public class EntityIdentifier {
|
|||
if ( entityBinding.getSuperEntityBinding() != null ) {
|
||||
throw new AssertionError( "Creating an identifier generator for a component on a subclass." );
|
||||
}
|
||||
final EntityIdentifier entityIdentifier = entityBinding.getHierarchyDetails().getEntityIdentifier();
|
||||
final Class entityClass = entityBinding.getEntity().getClassReference();
|
||||
final Class attributeDeclarer; // what class is the declarer of the composite pk attributes
|
||||
// IMPL NOTE : See the javadoc discussion on CompositeNestedGeneratedValueGenerator wrt the
|
||||
// various scenarios for which we need to account here
|
||||
//if ( idClassClass != null ) {
|
||||
|
|
|
@ -26,6 +26,7 @@ package org.hibernate.metamodel.spi.binding;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
|
@ -37,10 +38,8 @@ public class HibernateTypeDescriptor {
|
|||
private String explicitTypeName;
|
||||
private Map<String, String> typeParameters = new HashMap<String, String>( );
|
||||
|
||||
|
||||
private Type resolvedTypeMapping;
|
||||
private String javaTypeName;
|
||||
private boolean isToOne;
|
||||
private JavaClassReference javaClassReference;
|
||||
|
||||
public String getExplicitTypeName() {
|
||||
return explicitTypeName;
|
||||
|
@ -50,12 +49,12 @@ public class HibernateTypeDescriptor {
|
|||
this.explicitTypeName = explicitTypeName;
|
||||
}
|
||||
|
||||
public String getJavaTypeName() {
|
||||
return javaTypeName;
|
||||
public JavaClassReference getClassReference() {
|
||||
return javaClassReference;
|
||||
}
|
||||
|
||||
public void setJavaTypeName(String javaTypeName) {
|
||||
this.javaTypeName = javaTypeName;
|
||||
public void setClassReference(JavaClassReference javaClassReference) {
|
||||
this.javaClassReference = javaClassReference;
|
||||
}
|
||||
|
||||
public boolean isToOne() {
|
||||
|
@ -75,7 +74,7 @@ public class HibernateTypeDescriptor {
|
|||
}
|
||||
|
||||
public void copyFrom(HibernateTypeDescriptor hibernateTypeDescriptor) {
|
||||
setJavaTypeName( hibernateTypeDescriptor.getJavaTypeName() );
|
||||
setClassReference( hibernateTypeDescriptor.getClassReference() );
|
||||
setExplicitTypeName( hibernateTypeDescriptor.getExplicitTypeName() );
|
||||
getTypeParameters().putAll( hibernateTypeDescriptor.getTypeParameters() );
|
||||
setResolvedTypeMapping( hibernateTypeDescriptor.getResolvedTypeMapping() );
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.util.LinkedHashSet;
|
|||
import java.util.Set;
|
||||
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
|
||||
/**
|
||||
* Convenient base class for {@link AttributeContainer}. Because in our model all
|
||||
|
@ -40,17 +39,15 @@ import org.hibernate.internal.util.ValueHolder;
|
|||
*/
|
||||
public abstract class AbstractAttributeContainer implements AttributeContainer, Hierarchical {
|
||||
private final String name;
|
||||
private final String className;
|
||||
private final ValueHolder<Class<?>> classReference;
|
||||
private final JavaClassReference javaClassReference;
|
||||
private final Hierarchical superType;
|
||||
|
||||
private LinkedHashSet<Attribute> attributeSet = new LinkedHashSet<Attribute>();
|
||||
private HashMap<String, Attribute> attributeMap = new HashMap<String, Attribute>();
|
||||
|
||||
public AbstractAttributeContainer(String name, String className, ValueHolder<Class<?>> classReference, Hierarchical superType) {
|
||||
public AbstractAttributeContainer(String name, JavaClassReference javaClassReference, Hierarchical superType) {
|
||||
this.name = name;
|
||||
this.className = className;
|
||||
this.classReference = classReference;
|
||||
this.javaClassReference = javaClassReference;
|
||||
this.superType = superType;
|
||||
}
|
||||
|
||||
|
@ -60,18 +57,8 @@ public abstract class AbstractAttributeContainer implements AttributeContainer,
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getClassReference() {
|
||||
return classReference.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueHolder<Class<?>> getClassReferenceUnresolved() {
|
||||
return classReference;
|
||||
public JavaClassReference getClassReference() {
|
||||
return javaClassReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,11 +71,6 @@ public abstract class AbstractAttributeContainer implements AttributeContainer,
|
|||
return Collections.unmodifiableSet( attributeSet );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRoleBaseName() {
|
||||
return getClassName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Attribute locateAttribute(String name) {
|
||||
return attributeMap.get( name );
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.spi.domain;
|
||||
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
|
||||
/**
|
||||
* Models the notion of an aggregated composite (what JPA calls an Embeddable).
|
||||
* <p/>
|
||||
|
@ -33,8 +31,11 @@ import org.hibernate.internal.util.ValueHolder;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class Aggregate extends AbstractAttributeContainer {
|
||||
public Aggregate(String name, String className, ValueHolder<Class<?>> classReference, Hierarchical superType) {
|
||||
super( name, className, classReference, superType );
|
||||
final String roleBaseName;
|
||||
|
||||
public Aggregate(String roleBaseName, String name, JavaClassReference javaClassReference, Hierarchical superType) {
|
||||
super( name, javaClassReference, superType );
|
||||
this.roleBaseName = roleBaseName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,8 +50,6 @@ public class Aggregate extends AbstractAttributeContainer {
|
|||
|
||||
@Override
|
||||
public String getRoleBaseName() {
|
||||
// todo : this is not really completely accurate atm
|
||||
// the role base here should really be the role of the aggregated composite attribute.
|
||||
return getClassName();
|
||||
return roleBaseName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.spi.domain;
|
||||
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
|
||||
/**
|
||||
* Models a basic type.
|
||||
*
|
||||
|
@ -32,11 +30,15 @@ import org.hibernate.internal.util.ValueHolder;
|
|||
*/
|
||||
public class BasicType implements Type {
|
||||
private final String name;
|
||||
private final ValueHolder<Class<?>> classReference;
|
||||
private final JavaClassReference javaClassReference;
|
||||
|
||||
public BasicType(String name, ValueHolder<Class<?>> classReference) {
|
||||
public BasicType(String name, JavaClassReference javaClassReference) {
|
||||
this.name = name;
|
||||
this.classReference = classReference;
|
||||
this.javaClassReference = javaClassReference;
|
||||
}
|
||||
|
||||
public BasicType(JavaClassReference javaClassReference) {
|
||||
this( javaClassReference.getName(), javaClassReference );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,18 +47,8 @@ public class BasicType implements Type {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getClassReference() {
|
||||
return classReference.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueHolder<Class<?>> getClassReferenceUnresolved() {
|
||||
return classReference;
|
||||
public JavaClassReference getClassReference() {
|
||||
return javaClassReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* 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,
|
||||
* This program is distributed in nthe 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.
|
||||
|
@ -23,8 +23,6 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.spi.domain;
|
||||
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
|
||||
/**
|
||||
* Models the notion of an entity
|
||||
*
|
||||
|
@ -36,12 +34,11 @@ public class Entity extends AbstractAttributeContainer {
|
|||
* Constructor for the entity
|
||||
*
|
||||
* @param entityName The name of the entity
|
||||
* @param className The name of this entity's java class
|
||||
* @param classReference The reference to this entity's {@link Class}
|
||||
* @param javaClassReference The {@link JavaClassReference} reference to this entity's {@link Class}
|
||||
* @param superType The super type for this entity. If there is not super type {@code null} needs to be passed.
|
||||
*/
|
||||
public Entity(String entityName, String className, ValueHolder<Class<?>> classReference, Hierarchical superType) {
|
||||
super( entityName, className, classReference, superType );
|
||||
public Entity(String entityName, JavaClassReference javaClassReference, Hierarchical superType) {
|
||||
super( entityName, javaClassReference, superType );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,4 +50,9 @@ public class Entity extends AbstractAttributeContainer {
|
|||
public boolean isAggregate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRoleBaseName() {
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* 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.spi.domain;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
|
||||
/**
|
||||
* Models the naming of a Java type where we may not have access to that type's {@link Class} reference. Generally
|
||||
* speaking this is the case in various hibernate-tools and reverse-engineering use cases.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class JavaClassReference {
|
||||
|
||||
// ClassLoaderService.classForName( className ) does not work for primitives, so add mapping
|
||||
// from primitive class names -> class.
|
||||
private static final Map<String,Class<?>> primitiveClassesByName = new HashMap<String,Class<?>>();
|
||||
static {
|
||||
primitiveClassesByName.put("int", Integer.TYPE );
|
||||
primitiveClassesByName.put( "long", Long.TYPE );
|
||||
primitiveClassesByName.put( "double", Double.TYPE );
|
||||
primitiveClassesByName.put( "float", Float.TYPE );
|
||||
primitiveClassesByName.put( "bool", Boolean.TYPE );
|
||||
primitiveClassesByName.put( "char", Character.TYPE );
|
||||
primitiveClassesByName.put( "byte", Byte.TYPE );
|
||||
primitiveClassesByName.put( "void", Void.TYPE );
|
||||
primitiveClassesByName.put( "short", Short.TYPE );
|
||||
}
|
||||
private final String name;
|
||||
private final ValueHolder<Class<?>> classHolder;
|
||||
|
||||
public JavaClassReference(final String name, final ClassLoaderService classLoaderService) {
|
||||
if ( name == null || classLoaderService == null ) {
|
||||
throw new IllegalArgumentException( "name and classLoaderService must be non-null." );
|
||||
}
|
||||
this.name = name;
|
||||
|
||||
final Class<?> primitiveClass = primitiveClassesByName.get( name );
|
||||
if ( primitiveClass != null ) {
|
||||
this.classHolder = new ValueHolder<Class<?>>( primitiveClass );
|
||||
}
|
||||
else {
|
||||
this.classHolder = new ValueHolder<Class<?>>(
|
||||
new ValueHolder.DeferredInitializer<Class<?>>() {
|
||||
@Override
|
||||
public Class<?> initialize() {
|
||||
return classLoaderService.classForName( name );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public JavaClassReference(Class<?> theClass) {
|
||||
if ( theClass == null ) {
|
||||
throw new IllegalArgumentException( "theClass must be non-null." );
|
||||
}
|
||||
this.name = theClass.getName();
|
||||
this.classHolder = new ValueHolder<Class<?>>( theClass );
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Class<?> getResolvedClass() {
|
||||
return classHolder.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + "[name=" + name + "]";
|
||||
}
|
||||
}
|
|
@ -1,70 +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.spi.domain;
|
||||
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
|
||||
/**
|
||||
* Models the naming of a Java type where we may not have access to that type's {@link Class} reference. Generally
|
||||
* speaking this is the case in various hibernate-tools and reverse-engineering use cases.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class JavaType {
|
||||
private final String name;
|
||||
private final ValueHolder<Class<?>> classReference;
|
||||
|
||||
public JavaType(final String name, final ClassLoaderService classLoaderService) {
|
||||
this.name = name;
|
||||
this.classReference = new ValueHolder<Class<?>>(
|
||||
new ValueHolder.DeferredInitializer<Class<?>>() {
|
||||
@Override
|
||||
public Class<?> initialize() {
|
||||
return classLoaderService.classForName( name );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public JavaType(Class<?> theClass) {
|
||||
this.name = theClass.getName();
|
||||
this.classReference = new ValueHolder<Class<?>>( theClass );
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Class<?> getClassReference() {
|
||||
return classReference.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder( super.toString() )
|
||||
.append( "[name=" ).append( name ).append( "]" )
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -23,8 +23,6 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.spi.domain;
|
||||
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
|
||||
/**
|
||||
* Models the concept class in the hierarchy with no persistent attributes.
|
||||
*
|
||||
|
@ -35,12 +33,11 @@ public class NonEntity extends AbstractAttributeContainer {
|
|||
* Constructor for the non-entity
|
||||
*
|
||||
* @param entityName The name of the non-entity
|
||||
* @param className The name of this non-entity's java class
|
||||
* @param classReference The reference to this non-entity's {@link Class}
|
||||
* @param javaClassReference The reference to this non-entity's {@link Class}
|
||||
* @param superType The super type for this non-entity. If there is not super type {@code null} needs to be passed.
|
||||
*/
|
||||
public NonEntity(String entityName, String className, ValueHolder<Class<?>> classReference, Hierarchical superType) {
|
||||
super( entityName, className, classReference, superType );
|
||||
public NonEntity(String entityName, JavaClassReference javaClassReference, Hierarchical superType) {
|
||||
super( entityName, javaClassReference, superType );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,4 +49,9 @@ public class NonEntity extends AbstractAttributeContainer {
|
|||
public boolean isAggregate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRoleBaseName() {
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.spi.domain;
|
||||
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
|
||||
/**
|
||||
* Models the concept of a (intermediate) superclass
|
||||
*
|
||||
|
@ -35,12 +33,11 @@ public class Superclass extends AbstractAttributeContainer {
|
|||
* Constructor for the entity
|
||||
*
|
||||
* @param entityName The name of the entity
|
||||
* @param className The name of this entity's java class
|
||||
* @param classReference The reference to this entity's {@link Class}
|
||||
* @param javaClassReference The reference to this entity's {@link Class}
|
||||
* @param superType The super type for this entity. If there is not super type {@code null} needs to be passed.
|
||||
*/
|
||||
public Superclass(String entityName, String className, ValueHolder<Class<?>> classReference, Hierarchical superType) {
|
||||
super( entityName, className, classReference, superType );
|
||||
public Superclass(String entityName, JavaClassReference javaClassReference, Hierarchical superType) {
|
||||
super( entityName, javaClassReference, superType );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,4 +49,9 @@ public class Superclass extends AbstractAttributeContainer {
|
|||
public boolean isAggregate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRoleBaseName() {
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.spi.domain;
|
||||
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
|
||||
/**
|
||||
* Basic information about a Java type, in regards to its role in particular set of mappings.
|
||||
|
@ -38,13 +37,6 @@ public interface Type {
|
|||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Obtain the java class name for this type.
|
||||
*
|
||||
* @return The class name
|
||||
*/
|
||||
public String getClassName();
|
||||
|
||||
/**
|
||||
* Obtain the java {@link Class} reference for this type
|
||||
*
|
||||
|
@ -54,9 +46,7 @@ public interface Type {
|
|||
* could not be determined. Generally this is the case in reverse-engineering scenarios where the specified
|
||||
* domain model classes do not yet exist.
|
||||
*/
|
||||
public Class<?> getClassReference();
|
||||
|
||||
public ValueHolder<Class<?>> getClassReferenceUnresolved();
|
||||
public JavaClassReference getClassReference();
|
||||
|
||||
public boolean isAssociation();
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
package org.hibernate.metamodel.spi.source;
|
||||
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.metamodel.spi.MetadataImplementor;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.metamodel.spi.domain.Type;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
|
@ -43,11 +43,18 @@ public interface BindingContext {
|
|||
|
||||
public <T> Class<T> locateClassByName(String name);
|
||||
|
||||
public Type makeJavaType(String className);
|
||||
public Type makeDomainType(String className);
|
||||
|
||||
public boolean isGloballyQuotedIdentifiers();
|
||||
|
||||
public ValueHolder<Class<?>> makeClassReference(String className);
|
||||
public JavaClassReference makeJavaClassReference(String className);
|
||||
|
||||
public JavaClassReference makeJavaClassReference(Class<?> clazz);
|
||||
|
||||
public JavaClassReference makeJavaPropertyClassReference(
|
||||
JavaClassReference propertyContainerClassReference,
|
||||
String propertyName
|
||||
);
|
||||
|
||||
public String qualifyClassName(String name);
|
||||
}
|
||||
|
|
|
@ -23,15 +23,14 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.spi.source;
|
||||
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface ComponentAttributeSource extends SingularAttributeSource, AttributeSourceContainer {
|
||||
public String getClassName();
|
||||
|
||||
public ValueHolder<Class<?>> getClassReference();
|
||||
public JavaClassReference getClassReference();
|
||||
|
||||
public String getParentReferenceAttributeName();
|
||||
|
||||
|
|
|
@ -23,16 +23,15 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.spi.source;
|
||||
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface CompositePluralAttributeElementSource
|
||||
extends PluralAttributeElementSource, AttributeSourceContainer, CascadeStyleSource, MetaSource {
|
||||
public String getClassName();
|
||||
|
||||
public ValueHolder<Class<?>> getClassReference();
|
||||
public JavaClassReference getClassReference();
|
||||
|
||||
public String getParentReferenceAttributeName();
|
||||
|
||||
|
|
|
@ -23,14 +23,13 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.spi.source;
|
||||
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public interface CompositePluralAttributeIndexSource
|
||||
extends PluralAttributeIndexSource, AttributeSourceContainer {
|
||||
public String getClassName();
|
||||
|
||||
public ValueHolder<Class<?>> getClassReference();
|
||||
public JavaClassReference getClassReference();
|
||||
}
|
||||
|
|
|
@ -28,9 +28,9 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.metamodel.spi.binding.Caching;
|
||||
import org.hibernate.metamodel.spi.binding.CustomSQL;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
@ -45,7 +45,7 @@ public interface PluralAttributeSource
|
|||
|
||||
public FilterSource[] getFilterSources();
|
||||
|
||||
public ValueHolder<Class<?>> getElementClassReference();
|
||||
public JavaClassReference getElementJavaClassReference();
|
||||
|
||||
public TableSpecificationSource getCollectionTableSpecificationSource();
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ import org.hibernate.cache.spi.entry.CacheEntryStructure;
|
|||
import org.hibernate.cache.spi.entry.StructuredCollectionCacheEntry;
|
||||
import org.hibernate.cache.spi.entry.StructuredMapCacheEntry;
|
||||
import org.hibernate.cache.spi.entry.UnstructuredCacheEntry;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.collection.spi.PersistentCollection;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
|
@ -71,14 +70,6 @@ import org.hibernate.internal.util.collections.ArrayHelper;
|
|||
import org.hibernate.jdbc.Expectation;
|
||||
import org.hibernate.jdbc.Expectations;
|
||||
import org.hibernate.loader.collection.CollectionInitializer;
|
||||
import org.hibernate.mapping.Collection;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.Formula;
|
||||
import org.hibernate.mapping.IdentifierCollection;
|
||||
import org.hibernate.mapping.IndexedCollection;
|
||||
import org.hibernate.mapping.List;
|
||||
import org.hibernate.mapping.Selectable;
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.metadata.CollectionMetadata;
|
||||
import org.hibernate.metamodel.spi.MetadataImplementor;
|
||||
import org.hibernate.metamodel.spi.binding.AbstractPluralAttributeBinding;
|
||||
|
@ -568,7 +559,7 @@ public abstract class AbstractCollectionPersister
|
|||
|
||||
isInverse = keyBinding.isInverse();
|
||||
if ( isArray ) {
|
||||
elementClass = collection.getAttribute().getElementType().getClassReference();
|
||||
elementClass = collection.getAttribute().getElementType().getClassReference().getResolvedClass();
|
||||
}
|
||||
else {
|
||||
// for non-arrays, we don't need to know the element class
|
||||
|
|
|
@ -83,7 +83,7 @@ public class PojoInstantiator implements Instantiator, Serializable {
|
|||
this.mappedClass = entityIdentifier.getIdClassClass();
|
||||
}
|
||||
else {
|
||||
this.mappedClass = compositeAttributeBindingContainer.getClassReference();
|
||||
this.mappedClass = compositeAttributeBindingContainer.getClassReference().getResolvedClass();
|
||||
}
|
||||
this.isAbstract = ReflectHelper.isAbstractClass( mappedClass );
|
||||
this.optimizer = optimizer;
|
||||
|
@ -117,9 +117,11 @@ public class PojoInstantiator implements Instantiator, Serializable {
|
|||
}
|
||||
|
||||
public PojoInstantiator(EntityBinding entityBinding, ReflectionOptimizer.InstantiationOptimizer optimizer) {
|
||||
this.mappedClass = entityBinding.getEntity().getClassReference();
|
||||
this.mappedClass = entityBinding.getEntity().getClassReference().getResolvedClass();
|
||||
this.isAbstract = ReflectHelper.isAbstractClass( mappedClass );
|
||||
this.proxyInterface = entityBinding.getProxyInterfaceType() == null ? null : entityBinding.getProxyInterfaceType().getValue();
|
||||
this.proxyInterface = entityBinding.getProxyInterfaceType() == null ?
|
||||
null :
|
||||
entityBinding.getProxyInterfaceType().getResolvedClass();
|
||||
this.embeddedIdentifier = entityBinding.getHierarchyDetails().getEntityIdentifier().isNonAggregatedComposite();
|
||||
this.optimizer = optimizer;
|
||||
|
||||
|
|
|
@ -627,7 +627,7 @@ public final class PropertyFactory {
|
|||
}
|
||||
|
||||
try {
|
||||
return ReflectHelper.getDefaultConstructor( entityBinding.getEntity().getClassReference() );
|
||||
return ReflectHelper.getDefaultConstructor( entityBinding.getEntity().getClassReference().getResolvedClass() );
|
||||
}
|
||||
catch( Throwable t ) {
|
||||
return null;
|
||||
|
@ -644,13 +644,15 @@ public final class PropertyFactory {
|
|||
}
|
||||
|
||||
private static Getter getGetter(AttributeBinding mappingProperty) {
|
||||
if ( mappingProperty == null || mappingProperty.getContainer().getClassReference() == null ) {
|
||||
final EntityMode entityMode =
|
||||
mappingProperty.getContainer().seekEntityBinding().getHierarchyDetails().getEntityMode();
|
||||
if ( mappingProperty == null || entityMode != EntityMode.POJO ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PropertyAccessor pa = PropertyAccessorFactory.getPropertyAccessor( mappingProperty, EntityMode.POJO );
|
||||
return pa.getGetter(
|
||||
mappingProperty.getContainer().getClassReference(),
|
||||
mappingProperty.getContainer().getClassReference().getResolvedClass(),
|
||||
mappingProperty.getAttribute().getName()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ public class PojoComponentTuplizer extends AbstractComponentTuplizer {
|
|||
this.componentClass =
|
||||
isIdentifierMapper ?
|
||||
entityIdentifier.getIdClassClass() :
|
||||
component.getClassReference();
|
||||
component.getClassReference().getResolvedClass();
|
||||
|
||||
String[] getterNames = new String[propertySpan];
|
||||
String[] setterNames = new String[propertySpan];
|
||||
|
@ -213,7 +213,7 @@ public class PojoComponentTuplizer extends AbstractComponentTuplizer {
|
|||
CompositeAttributeBindingContainer compositeAttributeBindingContainer,
|
||||
boolean isIdentifierMapper) {
|
||||
if ( !compositeAttributeBindingContainer.isAggregated() &&
|
||||
ReflectHelper.isAbstractClass( compositeAttributeBindingContainer.getClassReference() ) ) {
|
||||
ReflectHelper.isAbstractClass( compositeAttributeBindingContainer.getClassReference().getResolvedClass() ) ) {
|
||||
return new ProxiedInstantiator( compositeAttributeBindingContainer );
|
||||
}
|
||||
if ( optimizer == null ) {
|
||||
|
@ -245,7 +245,7 @@ public class PojoComponentTuplizer extends AbstractComponentTuplizer {
|
|||
}
|
||||
else {
|
||||
return getGetter(
|
||||
compositeAttributeBindingContainer.getClassReference(),
|
||||
compositeAttributeBindingContainer.getClassReference().getResolvedClass(),
|
||||
attributeBinding.getAttribute().getName(),
|
||||
PropertyAccessorFactory.getPropertyAccessor( attributeBinding, EntityMode.POJO )
|
||||
);
|
||||
|
@ -271,7 +271,7 @@ public class PojoComponentTuplizer extends AbstractComponentTuplizer {
|
|||
}
|
||||
else {
|
||||
return getSetter(
|
||||
compositeAttributeBindingContainer.getClassReference(),
|
||||
compositeAttributeBindingContainer.getClassReference().getResolvedClass(),
|
||||
attributeBinding.getAttribute().getName(),
|
||||
PropertyAccessorFactory.getPropertyAccessor( attributeBinding, EntityMode.POJO )
|
||||
);
|
||||
|
@ -295,7 +295,7 @@ public class PojoComponentTuplizer extends AbstractComponentTuplizer {
|
|||
}
|
||||
|
||||
public ProxiedInstantiator(CompositeAttributeBindingContainer compositeAttributeBindingContainer) {
|
||||
this( compositeAttributeBindingContainer.getClassReference() );
|
||||
this( compositeAttributeBindingContainer.getClassReference().getResolvedClass() );
|
||||
}
|
||||
|
||||
private ProxiedInstantiator(Class<?> proxiedClass) {
|
||||
|
|
|
@ -51,7 +51,6 @@ import org.hibernate.mapping.Component;
|
|||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.domain.Aggregate;
|
||||
|
@ -796,8 +795,10 @@ public class EntityMetamodel implements Serializable {
|
|||
Class<?> proxyInterfaceClass = null;
|
||||
Class<?> mappedClass = null;
|
||||
if ( isPOJO ) {
|
||||
mappedClass = entityBinding.getEntity().getClassReference();
|
||||
proxyInterfaceClass = entityBinding.getProxyInterfaceType() == null ? null : entityBinding.getProxyInterfaceType().getValue();
|
||||
mappedClass = entityBinding.getEntity().getClassReference().getResolvedClass();
|
||||
proxyInterfaceClass = entityBinding.getProxyInterfaceType() == null ?
|
||||
null :
|
||||
entityBinding.getProxyInterfaceType().getResolvedClass();
|
||||
instrumentationMetadata = Environment.getBytecodeProvider().getEntityInstrumentationMetadata( mappedClass );
|
||||
}
|
||||
else {
|
||||
|
@ -993,7 +994,7 @@ public class EntityMetamodel implements Serializable {
|
|||
subclassEntityNames.add( subEntityBinding.getEntity().getName() );
|
||||
if ( isPOJO ) {
|
||||
entityNameByInheritenceClassMap.put(
|
||||
subEntityBinding.getEntity().getClassReference(),
|
||||
subEntityBinding.getEntity().getClassReference().getResolvedClass(),
|
||||
subEntityBinding.getEntity().getName() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,8 +118,11 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer {
|
|||
|
||||
public PojoEntityTuplizer(EntityMetamodel entityMetamodel, EntityBinding mappedEntity) {
|
||||
super( entityMetamodel, mappedEntity );
|
||||
this.mappedClass = mappedEntity.getEntity().getClassReference();
|
||||
this.proxyInterface = mappedEntity.getProxyInterfaceType() == null ? null : mappedEntity.getProxyInterfaceType().getValue(); this.lifecycleImplementor = Lifecycle.class.isAssignableFrom( mappedClass );
|
||||
this.mappedClass = mappedEntity.getEntity().getClassReference().getResolvedClass();
|
||||
this.proxyInterface = mappedEntity.getProxyInterfaceType() == null ?
|
||||
null :
|
||||
mappedEntity.getProxyInterfaceType().getResolvedClass();
|
||||
this.lifecycleImplementor = Lifecycle.class.isAssignableFrom( mappedClass );
|
||||
this.isInstrumented = entityMetamodel.isInstrumented();
|
||||
|
||||
for ( AttributeBinding property : mappedEntity.getAttributeBindingClosure() ) {
|
||||
|
@ -263,8 +266,8 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer {
|
|||
// determine all interfaces needed by the resulting proxy
|
||||
Set<Class> proxyInterfaces = new java.util.LinkedHashSet<Class>();
|
||||
|
||||
Class mappedClass = entityBinding.getClassReference();
|
||||
Class proxyInterface = entityBinding.getProxyInterfaceType().getValue();
|
||||
Class mappedClass = entityBinding.getClassReference().getResolvedClass();
|
||||
Class proxyInterface = entityBinding.getProxyInterfaceType().getResolvedClass();
|
||||
|
||||
if ( proxyInterface!=null && !mappedClass.equals( proxyInterface ) ) {
|
||||
if ( ! proxyInterface.isInterface() ) {
|
||||
|
@ -280,8 +283,8 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer {
|
|||
}
|
||||
|
||||
for ( EntityBinding subEntityBinding : entityBinding.getPostOrderSubEntityBindingClosure() ) {
|
||||
final Class subclassProxy = subEntityBinding.getProxyInterfaceType().getValue();
|
||||
final Class subclassClass = subEntityBinding.getClassReference();
|
||||
final Class subclassProxy = subEntityBinding.getProxyInterfaceType().getResolvedClass();
|
||||
final Class subclassClass = subEntityBinding.getClassReference().getResolvedClass();
|
||||
if ( subclassProxy!=null && !subclassClass.equals( subclassProxy ) ) {
|
||||
if ( ! subclassProxy.isInterface() ) {
|
||||
throw new MappingException(
|
||||
|
@ -431,14 +434,14 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer {
|
|||
|
||||
private Getter getGetter(AttributeBinding mappedProperty) throws PropertyNotFoundException, MappingException {
|
||||
return getPropertyAccessor( mappedProperty ).getGetter(
|
||||
mappedProperty.getContainer().getClassReference(),
|
||||
mappedProperty.getContainer().getClassReference().getResolvedClass(),
|
||||
mappedProperty.getAttribute().getName()
|
||||
);
|
||||
}
|
||||
|
||||
private Setter getSetter(AttributeBinding mappedProperty) throws PropertyNotFoundException, MappingException {
|
||||
return getPropertyAccessor( mappedProperty ).getSetter(
|
||||
mappedProperty.getContainer().getClassReference(),
|
||||
mappedProperty.getContainer().getClassReference().getResolvedClass(),
|
||||
mappedProperty.getAttribute().getName()
|
||||
);
|
||||
}
|
||||
|
@ -460,7 +463,7 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer {
|
|||
}
|
||||
}
|
||||
return PropertyAccessorFactory.getPropertyAccessor(
|
||||
mappedProperty.getContainer().getClassReference(),
|
||||
mappedProperty.getContainer().getClassReference().getResolvedClass(),
|
||||
mappedProperty.getPropertyAccessorName()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -395,7 +395,7 @@ public class EmbeddableBindingTest extends BaseAnnotationBindingTestCase {
|
|||
assertEquals(
|
||||
"Wrong resolved type",
|
||||
"int",
|
||||
attribute.getAttribute().getSingularAttributeType().getClassName()
|
||||
attribute.getAttribute().getSingularAttributeType().getClassReference().getName()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,8 @@ public class EnumeratedBindingTest extends BaseAnnotationBindingTestCase {
|
|||
AttributeBinding attributeBinding = binding.locateAttributeBinding( "customerType" );
|
||||
HibernateTypeDescriptor descriptor = attributeBinding.getHibernateTypeDescriptor();
|
||||
assertEquals( org.hibernate.type.EnumType.class.getName(), descriptor.getExplicitTypeName() );
|
||||
assertEquals( CustomerType.class.getName(), descriptor.getJavaTypeName() );
|
||||
assertEquals( CustomerType.class.getName(), descriptor.getClassReference().getName() );
|
||||
assertEquals( CustomerType.class, descriptor.getClassReference().getResolvedClass() );
|
||||
assertNotNull( descriptor.getResolvedTypeMapping() );
|
||||
assertFalse( descriptor.getTypeParameters().isEmpty() );
|
||||
assertEquals(
|
||||
|
@ -94,7 +95,8 @@ public class EnumeratedBindingTest extends BaseAnnotationBindingTestCase {
|
|||
attributeBinding = binding.locateAttributeBinding( "orderType" );
|
||||
descriptor = attributeBinding.getHibernateTypeDescriptor();
|
||||
assertEquals( org.hibernate.type.EnumType.class.getName(), descriptor.getExplicitTypeName() );
|
||||
assertEquals( OrderType.class.getName(), descriptor.getJavaTypeName() );
|
||||
assertEquals( OrderType.class.getName(), descriptor.getClassReference().getName() );
|
||||
assertEquals( OrderType.class, descriptor.getClassReference().getResolvedClass() );
|
||||
assertNotNull( descriptor.getResolvedTypeMapping() );
|
||||
assertFalse( descriptor.getTypeParameters().isEmpty() );
|
||||
assertEquals(
|
||||
|
|
|
@ -77,8 +77,8 @@ public class InheritanceBindingTest extends BaseAnnotationBindingTestCase {
|
|||
public void testSubclassEntitySuperType() {
|
||||
EntityBinding entityBinding = getEntityBinding( SubclassOfSingleTableInheritance.class );
|
||||
assertNotNull( entityBinding.getEntity().getSuperType() );
|
||||
assertSame( RootOfSingleTableInheritance.class, entityBinding.getEntity().getSuperType().getClassReference() );
|
||||
assertEquals( RootOfSingleTableInheritance.class.getName(), entityBinding.getEntity().getSuperType().getClassName() );
|
||||
assertSame( RootOfSingleTableInheritance.class, entityBinding.getEntity().getSuperType().getClassReference().getResolvedClass() );
|
||||
assertEquals( RootOfSingleTableInheritance.class.getName(), entityBinding.getEntity().getSuperType().getClassReference().getName() );
|
||||
assertNull( entityBinding.getEntity().getSuperType().getSuperType() );
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@ import org.hibernate.type.PrimitiveCharacterArrayClobType;
|
|||
import org.hibernate.type.SerializableToBlobType;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.WrappedMaterializedBlobType;
|
||||
import org.hibernate.usertype.DynamicParameterizedType;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
@ -117,7 +116,8 @@ public class LobBindingTests extends BaseAnnotationBindingTestCase {
|
|||
private void checkHibernateTypeDescriptor(ExpectedValue expectedValue, String attributeName) {
|
||||
HibernateTypeDescriptor descriptor = getTypeDescriptor( attributeName );
|
||||
assertEquals( expectedValue.explicitTypeName, descriptor.getExplicitTypeName() );
|
||||
assertEquals( expectedValue.javaTypeName, descriptor.getJavaTypeName() );
|
||||
assertEquals( expectedValue.javaTypeName, descriptor.getClassReference().getName() );
|
||||
assertEquals( expectedValue.javaTypeName, descriptor.getClassReference().getResolvedClass().getName() );
|
||||
assertEquals( expectedValue.isResolvedTypeMappingNull, descriptor.getResolvedTypeMapping() == null );
|
||||
assertEquals( expectedValue.resolvedTypeMappingClass, descriptor.getResolvedTypeMapping().getClass() );
|
||||
assertEquals( expectedValue.isTypeParametersNull, descriptor.getTypeParameters() == null );
|
||||
|
|
|
@ -48,7 +48,7 @@ public class ProxyBindingTest extends BaseAnnotationBindingTestCase {
|
|||
public void testProxyNoAttributes() {
|
||||
EntityBinding binding = getEntityBinding( ProxiedEntity.class );
|
||||
assertTrue( "Wrong laziness", binding.isLazy() );
|
||||
assertEquals( "Wrong proxy interface", ProxiedEntity.class, binding.getProxyInterfaceType().getValue() );
|
||||
assertEquals( "Wrong proxy interface", ProxiedEntity.class, binding.getProxyInterfaceType().getResolvedClass() );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -56,7 +56,7 @@ public class ProxyBindingTest extends BaseAnnotationBindingTestCase {
|
|||
public void testNoProxy() {
|
||||
EntityBinding binding = getEntityBinding( NoProxyEntity.class );
|
||||
assertTrue( "Wrong laziness", binding.isLazy() );
|
||||
assertEquals( "Wrong proxy interface", NoProxyEntity.class, binding.getProxyInterfaceType().getValue() );
|
||||
assertEquals( "Wrong proxy interface", NoProxyEntity.class, binding.getProxyInterfaceType().getResolvedClass() );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -75,7 +75,7 @@ public class ProxyBindingTest extends BaseAnnotationBindingTestCase {
|
|||
assertEquals(
|
||||
"Wrong proxy interface",
|
||||
ProxyBindingTest.ProxyInterfaceEntity.class.getName(),
|
||||
binding.getProxyInterfaceType().getValue().getName()
|
||||
binding.getProxyInterfaceType().getResolvedClass().getName()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,8 @@ public class TemporalBindingTest extends BaseAnnotationBindingTestCase {
|
|||
AttributeBinding attributeBinding = binding.locateAttributeBinding( "date" );
|
||||
HibernateTypeDescriptor descriptor = attributeBinding.getHibernateTypeDescriptor();
|
||||
assertEquals( "timestamp", descriptor.getExplicitTypeName() );
|
||||
assertEquals( Date.class.getName(), descriptor.getJavaTypeName() );
|
||||
assertEquals( Date.class.getName(), descriptor.getClassReference().getName() );
|
||||
assertEquals( Date.class, descriptor.getClassReference().getResolvedClass() );
|
||||
assertNotNull( descriptor.getResolvedTypeMapping() );
|
||||
assertEquals( TimestampType.class, descriptor.getResolvedTypeMapping().getClass() );
|
||||
assertNotNull( descriptor.getTypeParameters() );
|
||||
|
@ -84,7 +85,8 @@ public class TemporalBindingTest extends BaseAnnotationBindingTestCase {
|
|||
AttributeBinding attributeBinding = binding.locateAttributeBinding( "date" );
|
||||
HibernateTypeDescriptor descriptor = attributeBinding.getHibernateTypeDescriptor();
|
||||
assertEquals( "timestamp", descriptor.getExplicitTypeName() );
|
||||
assertEquals( Date.class.getName(), descriptor.getJavaTypeName() );
|
||||
assertEquals( Date.class.getName(), descriptor.getClassReference().getName() );
|
||||
assertEquals( Date.class, descriptor.getClassReference().getResolvedClass() );
|
||||
assertNotNull( descriptor.getResolvedTypeMapping() );
|
||||
assertEquals( TimestampType.class, descriptor.getResolvedTypeMapping().getClass() );
|
||||
assertNotNull( descriptor.getTypeParameters() );
|
||||
|
|
|
@ -97,7 +97,8 @@ public class VersionBindingTests extends BaseAnnotationBindingTestCase {
|
|||
.getVersioningAttributeBinding()
|
||||
.getHibernateTypeDescriptor();
|
||||
// assertEquals( "Long", descriptor.getExplicitTypeName() );
|
||||
assertEquals( Long.class.getName(), descriptor.getJavaTypeName() );
|
||||
assertEquals( Long.class.getName(), descriptor.getClassReference().getName() );
|
||||
assertEquals( Long.class, descriptor.getClassReference().getResolvedClass() );
|
||||
assertNotNull( descriptor.getResolvedTypeMapping() );
|
||||
assertEquals( LongType.class, descriptor.getResolvedTypeMapping().getClass() );
|
||||
assertNotNull( descriptor.getTypeParameters() );
|
||||
|
@ -131,7 +132,8 @@ public class VersionBindingTests extends BaseAnnotationBindingTestCase {
|
|||
.getVersioningAttributeBinding()
|
||||
.getHibernateTypeDescriptor();
|
||||
assertEquals( "dbtimestamp", descriptor.getExplicitTypeName() );
|
||||
assertEquals( Date.class.getName(), descriptor.getJavaTypeName() );
|
||||
assertEquals( Date.class.getName(), descriptor.getClassReference().getName() );
|
||||
assertEquals( Date.class, descriptor.getClassReference().getResolvedClass() );
|
||||
assertNotNull( descriptor.getResolvedTypeMapping() );
|
||||
assertEquals( DbTimestampType.class, descriptor.getResolvedTypeMapping().getClass() );
|
||||
assertNotNull( descriptor.getTypeParameters() );
|
||||
|
|
|
@ -175,7 +175,7 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
|||
assertEquals( expectedNullable, manyToOneAttributeBinding.isNullable() );
|
||||
HibernateTypeDescriptor hibernateTypeDescriptor = manyToOneAttributeBinding.getHibernateTypeDescriptor();
|
||||
Assert.assertNull( hibernateTypeDescriptor.getExplicitTypeName() );
|
||||
Assert.assertEquals( referencedEntityName, hibernateTypeDescriptor.getJavaTypeName() );
|
||||
Assert.assertEquals( referencedEntityName, hibernateTypeDescriptor.getClassReference().getName() );
|
||||
assertTrue( hibernateTypeDescriptor.isToOne() );
|
||||
assertTrue( hibernateTypeDescriptor.getTypeParameters().isEmpty() );
|
||||
|
||||
|
@ -192,7 +192,7 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
|||
);
|
||||
Entity simpleEntityAttributeType = (Entity) simpleEntitySingularAttribute.getSingularAttributeType();
|
||||
assertEquals( referencedEntityName, simpleEntityAttributeType.getName() );
|
||||
Assert.assertEquals( referencedEntityName, simpleEntityAttributeType.getClassName());
|
||||
Assert.assertEquals( referencedEntityName, simpleEntityAttributeType.getClassReference().getName());
|
||||
Assert.assertTrue( simpleEntityAttributeType.isAssociation() );
|
||||
assertFalse( simpleEntityAttributeType.isAggregate() );
|
||||
|
||||
|
@ -272,7 +272,7 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
|||
assertFalse( singularIdAttributeBinding.isNullable() );
|
||||
SingularAttribute singularIdAttribute = ( SingularAttribute ) idAttributeBinding.getAttribute();
|
||||
BasicType basicIdAttributeType = ( BasicType ) singularIdAttribute.getSingularAttributeType();
|
||||
assertSame( Long.class, basicIdAttributeType.getClassReference() );
|
||||
assertSame( Long.class, basicIdAttributeType.getClassReference().getResolvedClass() );
|
||||
|
||||
assertTrue( singularIdAttributeBinding.getRelationalValueBindings().size() == 1 );
|
||||
Value value = singularIdAttributeBinding.getRelationalValueBindings().get( 0 ).getValue();
|
||||
|
@ -293,7 +293,7 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
|||
assertNotNull( nameBinding.getRelationalValueBindings().size() );
|
||||
SingularAttribute singularNameAttribute = nameBinding.getAttribute();
|
||||
BasicType basicNameAttributeType = (BasicType) singularNameAttribute.getSingularAttributeType();
|
||||
assertSame( String.class, basicNameAttributeType.getClassReference() );
|
||||
assertSame( String.class, basicNameAttributeType.getClassReference().getResolvedClass() );
|
||||
Assert.assertEquals( 1, nameBinding.getRelationalValueBindings().size() );
|
||||
Value nameValue = nameBinding.getRelationalValueBindings().get( 0 ).getValue();
|
||||
assertTrue( nameValue instanceof Column );
|
||||
|
|
|
@ -31,10 +31,11 @@ import java.util.List;
|
|||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||
import org.hibernate.internal.util.ValueHolder;
|
||||
import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.spi.domain.Entity;
|
||||
import org.hibernate.metamodel.spi.domain.JavaClassReference;
|
||||
import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
||||
import org.hibernate.metamodel.spi.relational.Column;
|
||||
import org.hibernate.metamodel.spi.relational.Identifier;
|
||||
|
@ -55,6 +56,8 @@ public class SimpleValueBindingTests extends BaseUnitTestCase {
|
|||
public static final JdbcDataType BIGINT = new JdbcDataType( Types.BIGINT, "BIGINT", Long.class );
|
||||
public static final JdbcDataType VARCHAR = new JdbcDataType( Types.VARCHAR, "VARCHAR", String.class );
|
||||
|
||||
private static final ClassLoaderService classLoaderService = new ClassLoaderServiceImpl();
|
||||
|
||||
|
||||
@Test
|
||||
public void testBasicMiddleOutBuilding() {
|
||||
|
@ -66,7 +69,7 @@ public class SimpleValueBindingTests extends BaseUnitTestCase {
|
|||
table.getPrimaryKey().addColumn( idColumn );
|
||||
table.getPrimaryKey().setName( "my_table_pk" );
|
||||
|
||||
Entity entity = new Entity( "TheEntity", "NoSuchClass", makeJavaType( "NoSuchClass" ), null );
|
||||
Entity entity = new Entity( "TheEntity", makeJavaType( "NoSuchClass" ), null );
|
||||
EntityBinding entityBinding = new EntityBinding( InheritanceType.NO_INHERITANCE, EntityMode.POJO );
|
||||
entityBinding.setEntity( entity );
|
||||
entityBinding.setPrimaryTable( table );
|
||||
|
@ -103,19 +106,7 @@ public class SimpleValueBindingTests extends BaseUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
ValueHolder<Class<?>> makeJavaType(final String name) {
|
||||
return new ValueHolder<Class<?>>(
|
||||
new ValueHolder.DeferredInitializer<Class<?>>() {
|
||||
@Override
|
||||
public Class<?> initialize() {
|
||||
try {
|
||||
return Class.forName( name );
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
throw new ClassLoadingException( "Could not load class : " + name, e );
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
JavaClassReference makeJavaType(final String name) {
|
||||
return new JavaClassReference( name, classLoaderService );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,7 +158,8 @@ public abstract class AbstractBasicCollectionBindingTests extends BaseUnitTestCa
|
|||
assertSame( collectionBinding, keyBinding.getPluralAttributeBinding() );
|
||||
HibernateTypeDescriptor collectionHibernateTypeDescriptor = collectionBinding.getHibernateTypeDescriptor();
|
||||
assertNull( collectionHibernateTypeDescriptor.getExplicitTypeName() );
|
||||
assertEquals( expectedCollectionJavaClass.getName(), collectionHibernateTypeDescriptor.getJavaTypeName() );
|
||||
assertEquals( expectedCollectionJavaClass, collectionHibernateTypeDescriptor.getClassReference().getResolvedClass() );
|
||||
assertEquals( expectedCollectionJavaClass.getName(), collectionHibernateTypeDescriptor.getClassReference().getName() );
|
||||
assertTrue( collectionHibernateTypeDescriptor.getTypeParameters().isEmpty() );
|
||||
assertTrue( expectedCollectionTypeClass.isInstance( collectionHibernateTypeDescriptor.getResolvedTypeMapping() ) );
|
||||
assertFalse( collectionHibernateTypeDescriptor.getResolvedTypeMapping().isComponentType() );
|
||||
|
@ -197,9 +198,13 @@ public abstract class AbstractBasicCollectionBindingTests extends BaseUnitTestCa
|
|||
PluralAttributeElementBinding.Nature.BASIC,
|
||||
collectionBinding.getPluralAttributeElementBinding().getNature()
|
||||
);
|
||||
assertEquals(
|
||||
expectedElementJavaClass,
|
||||
collectionBinding.getPluralAttributeElementBinding().getHibernateTypeDescriptor().getClassReference().getResolvedClass()
|
||||
);
|
||||
assertEquals(
|
||||
expectedElementJavaClass.getName(),
|
||||
collectionBinding.getPluralAttributeElementBinding().getHibernateTypeDescriptor().getJavaTypeName()
|
||||
collectionBinding.getPluralAttributeElementBinding().getHibernateTypeDescriptor().getClassReference().getName()
|
||||
);
|
||||
assertEquals(
|
||||
expectedElementJavaClass,
|
||||
|
@ -226,7 +231,7 @@ public abstract class AbstractBasicCollectionBindingTests extends BaseUnitTestCa
|
|||
|
||||
private void checkEquals(HibernateTypeDescriptor expected, HibernateTypeDescriptor actual) {
|
||||
assertEquals( expected.getExplicitTypeName(), actual.getExplicitTypeName() );
|
||||
assertEquals( expected.getJavaTypeName(), actual.getJavaTypeName() );
|
||||
assertEquals( expected.getClassReference(), actual.getClassReference() );
|
||||
assertEquals( expected.getTypeParameters(), actual.getTypeParameters() );
|
||||
assertEquals( expected.getResolvedTypeMapping(), actual.getResolvedTypeMapping() );
|
||||
assertEquals( expected.isToOne(), actual.isToOne() );
|
||||
|
|
|
@ -193,7 +193,8 @@ public abstract class AbstractUnidirectionalOneToManyBindingTests extends BaseUn
|
|||
|
||||
final HibernateTypeDescriptor collectionHibernateTypeDescriptor = collectionBinding.getHibernateTypeDescriptor();
|
||||
assertNull( collectionHibernateTypeDescriptor.getExplicitTypeName() );
|
||||
assertEquals( expectedCollectionJavaType.getName(), collectionHibernateTypeDescriptor.getJavaTypeName() );
|
||||
assertEquals( expectedCollectionJavaType.getName(), collectionHibernateTypeDescriptor.getClassReference().getName() );
|
||||
assertEquals( expectedCollectionJavaType, collectionHibernateTypeDescriptor.getClassReference().getResolvedClass() );
|
||||
assertTrue( collectionHibernateTypeDescriptor.getTypeParameters().isEmpty() );
|
||||
assertTrue( expectedCollectionTypeClass.isInstance( collectionHibernateTypeDescriptor.getResolvedTypeMapping() ) );
|
||||
assertFalse( collectionHibernateTypeDescriptor.getResolvedTypeMapping().isComponentType() );
|
||||
|
@ -238,13 +239,13 @@ public abstract class AbstractUnidirectionalOneToManyBindingTests extends BaseUn
|
|||
|
||||
assertEquals(
|
||||
expectedElementEntityBinding.getEntity().getName(),
|
||||
collectionBinding.getPluralAttributeElementBinding().getHibernateTypeDescriptor().getJavaTypeName()
|
||||
collectionBinding.getPluralAttributeElementBinding().getHibernateTypeDescriptor().getClassReference().getName()
|
||||
);
|
||||
}
|
||||
|
||||
private void checkEquals(HibernateTypeDescriptor expected, HibernateTypeDescriptor actual) {
|
||||
assertEquals( expected.getExplicitTypeName(), actual.getExplicitTypeName() );
|
||||
assertEquals( expected.getJavaTypeName(), actual.getJavaTypeName() );
|
||||
assertEquals( expected.getClassReference(), actual.getClassReference() );
|
||||
assertEquals( expected.getTypeParameters(), actual.getTypeParameters() );
|
||||
assertEquals( expected.getResolvedTypeMapping(), actual.getResolvedTypeMapping() );
|
||||
assertEquals( expected.isToOne(), actual.isToOne() );
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.hibernate.Session;
|
|||
import org.hibernate.Transaction;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -46,7 +45,6 @@ import static org.junit.Assert.assertTrue;
|
|||
/**
|
||||
* @author Gavin King
|
||||
*/
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public class DynamicClassTest extends BaseCoreFunctionalTestCase {
|
||||
@Override
|
||||
public String[] getMappings() {
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public class SubclassDynamicMapTest extends BaseCoreFunctionalTestCase {
|
||||
@Override
|
||||
public String[] getMappings() {
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
|||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public class MapTest extends LegacyTestCase {
|
||||
@Override
|
||||
public String[] getMappings() {
|
||||
|
@ -53,6 +52,7 @@ public class MapTest extends LegacyTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public void testMap() throws Exception {
|
||||
Session s = openSession();
|
||||
s.beginTransaction();
|
||||
|
@ -120,6 +120,7 @@ public class MapTest extends LegacyTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public void testMapOneToOne() throws Exception {
|
||||
Map child = new HashMap();
|
||||
Map parent = new HashMap();
|
||||
|
|
|
@ -20,7 +20,6 @@ import static org.junit.Assert.assertNotNull;
|
|||
/**
|
||||
* @author Gavin King
|
||||
*/
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public class DynamicMapOneToOneTest extends BaseCoreFunctionalTestCase {
|
||||
@Override
|
||||
public String[] getMappings() {
|
||||
|
|
|
@ -55,7 +55,6 @@ import static org.junit.Assert.fail;
|
|||
/**
|
||||
* @author Gavin King
|
||||
*/
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public class CMTTest extends BaseCoreFunctionalTestCase {
|
||||
@Override
|
||||
public String[] getMappings() {
|
||||
|
@ -81,6 +80,7 @@ public class CMTTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public void testConcurrent() throws Exception {
|
||||
sessionFactory().getStatistics().clear();
|
||||
assertEquals( 0, sessionFactory().getStatistics().getUpdateTimestampsCacheHitCount() );
|
||||
|
|
|
@ -25,9 +25,6 @@ package org.hibernate.test.util;
|
|||
import java.util.Iterator;
|
||||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.metamodel.Metadata;
|
||||
import org.hibernate.metamodel.spi.MetadataImplementor;
|
||||
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
|
||||
|
@ -99,9 +96,8 @@ public class SchemaUtil {
|
|||
Iterator<PluralAttributeBinding> collectionBindings = metadata.getCollectionBindings().iterator();
|
||||
while ( collectionBindings.hasNext() ) {
|
||||
PluralAttributeBinding collectionBinding = collectionBindings.next();
|
||||
if ( collectionBinding.getAttribute().getName().equals( fieldName )
|
||||
&& collectionBinding.getAttribute().getAttributeContainer().getClassReference()
|
||||
.equals( entityClass ) ) {
|
||||
if ( collectionBinding.getAttribute().getName().equals( fieldName ) && entityClass.equals(
|
||||
collectionBinding.getAttribute().getAttributeContainer().getClassReference().getResolvedClass() ) ) {
|
||||
return collectionBinding;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,6 @@ import org.hibernate.metamodel.SessionFactoryBuilder;
|
|||
import org.hibernate.metamodel.spi.MetadataImplementor;
|
||||
import org.hibernate.metamodel.spi.TypeContributor;
|
||||
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.spi.source.MappingException;
|
||||
import org.hibernate.secure.spi.GrantedPermission;
|
||||
import org.hibernate.secure.spi.JaccPermissionDeclarations;
|
||||
import org.hibernate.secure.spi.JaccService;
|
||||
|
@ -332,7 +331,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
|||
private List<String> collectNamesOfClassesToEnhance(MetadataImplementor metadata) {
|
||||
final List<String> entityClassNames = new ArrayList<String>();
|
||||
for ( EntityBinding eb : metadata.getEntityBindings() ) {
|
||||
entityClassNames.add( eb.getEntity().getClassName() );
|
||||
entityClassNames.add( eb.getEntity().getClassReference().getName() );
|
||||
}
|
||||
return entityClassNames;
|
||||
}
|
||||
|
|
|
@ -28,9 +28,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.jpa.event.spi.jpa.Callback;
|
||||
import org.hibernate.jpa.event.spi.jpa.ListenerFactory;
|
||||
|
|
|
@ -126,7 +126,7 @@ public class MetamodelBuilder {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
private EntityTypeImpl buildEntityType(EntityBinding entityBinding) {
|
||||
final Class javaType = entityBinding.getClassReference();
|
||||
final Class javaType = entityBinding.getClassReference().getResolvedClass();
|
||||
final AbstractIdentifiableType superType = locateOrBuildSuperType( entityBinding.getEntity().getSuperType(), entityBinding );
|
||||
|
||||
EntityTypeImpl entityType = new EntityTypeImpl(
|
||||
|
@ -180,13 +180,13 @@ public class MetamodelBuilder {
|
|||
else {
|
||||
throw new IllegalStateException(
|
||||
"Unexpected type for entity super descriptor; expecting Entity or Superclass, found ["
|
||||
+ superDescriptor.getClassName() + "]"
|
||||
+ superDescriptor.getClassReference().getName() + "]"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private MappedSuperclassTypeImpl locateOrBuildMappedSuperclassType(Superclass superDescriptor, EntityBinding entityBinding) {
|
||||
MappedSuperclassTypeImpl mappedSuperclassType = mappedSuperclassTypeMap.get( superDescriptor.getClassReference() );
|
||||
MappedSuperclassTypeImpl mappedSuperclassType = mappedSuperclassTypeMap.get( superDescriptor.getClassReference().getResolvedClass() );
|
||||
if ( mappedSuperclassType == null ) {
|
||||
mappedSuperclassType = buildMappedSuperclassType( superDescriptor, entityBinding );
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public class MetamodelBuilder {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
private MappedSuperclassTypeImpl buildMappedSuperclassType(Superclass superDescriptor, EntityBinding entityBinding) {
|
||||
final Class javaType = superDescriptor.getClassReference();
|
||||
final Class javaType = superDescriptor.getClassReference().getResolvedClass();
|
||||
final AbstractIdentifiableType superSuperType = locateOrBuildSuperType( superDescriptor, entityBinding );
|
||||
|
||||
MappedSuperclassTypeImpl mappedSuperclassType = new MappedSuperclassTypeImpl(
|
||||
|
|
Loading…
Reference in New Issue