HHH-6159 - Create EntityManagerFactoryBuilder : integrate EntityManagerFactoryBuilder with metamodel codebase
This commit is contained in:
parent
61c04a0b30
commit
288155bcb2
|
@ -757,7 +757,12 @@ public final class SessionFactoryImpl
|
|||
// Prepare persisters and link them up with their cache
|
||||
// region/access-strategy
|
||||
|
||||
final MetamodelBuilder jpaMetamodelBuilder = new MetamodelBuilder( this );
|
||||
final MetamodelBuilder jpaMetamodelBuilder = new MetamodelBuilder(
|
||||
this,
|
||||
JpaMetaModelPopulationSetting.parse(
|
||||
properties.getProperty( AvailableSettings.JPA_METAMODEL_POPULATION )
|
||||
)
|
||||
);
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
if ( settings.getCacheRegionPrefix() != null) {
|
||||
|
|
|
@ -62,9 +62,7 @@ public abstract class AbstractIdentifiableType<X>
|
|||
isVersioned = versioned;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public AbstractIdentifiableType<? super X> getSupertype() {
|
||||
return ( AbstractIdentifiableType<? super X> ) super.getSupertype();
|
||||
}
|
||||
|
@ -87,16 +85,12 @@ public abstract class AbstractIdentifiableType<X>
|
|||
return getSupertype();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean hasSingleIdAttribute() {
|
||||
return hasIdentifierProperty;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public <Y> SingularAttribute<? super X, Y> getId(Class<Y> javaType) {
|
||||
final SingularAttribute<? super X, Y> id_;
|
||||
|
@ -137,10 +131,7 @@ public abstract class AbstractIdentifiableType<X>
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public <Y> SingularAttribute<X, Y> getDeclaredId(Class<Y> javaType) {
|
||||
checkDeclaredId();
|
||||
|
@ -161,9 +152,7 @@ public abstract class AbstractIdentifiableType<X>
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Type<?> getIdType() {
|
||||
if ( id != null ) {
|
||||
checkSimpleId();
|
||||
|
@ -179,9 +168,7 @@ public abstract class AbstractIdentifiableType<X>
|
|||
( getSupertype() != null && getSupertype().hasIdClassAttributesDefined() );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Set<SingularAttribute<? super X, ?>> getIdClassAttributes() {
|
||||
if ( idClassAttributes != null ) {
|
||||
checkIdClass();
|
||||
|
@ -215,9 +202,7 @@ public abstract class AbstractIdentifiableType<X>
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean hasVersionAttribute() {
|
||||
return isVersioned;
|
||||
}
|
||||
|
@ -226,9 +211,7 @@ public abstract class AbstractIdentifiableType<X>
|
|||
return isVersioned && version != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public <Y> SingularAttribute<? super X, Y> getVersion(Class<Y> javaType) {
|
||||
if ( ! hasVersionAttribute() ) {
|
||||
|
@ -247,9 +230,7 @@ public abstract class AbstractIdentifiableType<X>
|
|||
return version_;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public <Y> SingularAttribute<X, Y> getDeclaredVersion(Class<Y> javaType) {
|
||||
checkDeclaredVersion();
|
||||
|
@ -279,14 +260,17 @@ public abstract class AbstractIdentifiableType<X>
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<X> getBuilder() {
|
||||
final AbstractManagedType.Builder<X> managedBuilder = super.getBuilder();
|
||||
return new Builder<X>() {
|
||||
@Override
|
||||
public void applyIdAttribute(SingularAttributeImpl<X, ?> idAttribute) {
|
||||
AbstractIdentifiableType.this.id = idAttribute;
|
||||
managedBuilder.addAttribute( idAttribute );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyIdClassAttributes(Set<SingularAttribute<? super X,?>> idClassAttributes) {
|
||||
for ( SingularAttribute<? super X,?> idClassAttribute : idClassAttributes ) {
|
||||
if ( AbstractIdentifiableType.this == idClassAttribute.getDeclaringType() ) {
|
||||
|
@ -297,12 +281,13 @@ public abstract class AbstractIdentifiableType<X>
|
|||
}
|
||||
AbstractIdentifiableType.this.idClassAttributes = idClassAttributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyVersionAttribute(SingularAttributeImpl<X, ?> versionAttribute) {
|
||||
AbstractIdentifiableType.this.version = versionAttribute;
|
||||
managedBuilder.addAttribute( versionAttribute );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAttribute(Attribute<X, ?> attribute) {
|
||||
managedBuilder.addAttribute( attribute );
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ public abstract class AbstractManagedType<X>
|
|||
throw new IllegalStateException( "Type has been locked" );
|
||||
}
|
||||
return new Builder<X>() {
|
||||
@Override
|
||||
public void addAttribute(Attribute<X,?> attribute) {
|
||||
declaredAttributes.put( attribute.getName(), attribute );
|
||||
final Bindable.BindableType bindableType = ( ( Bindable ) attribute ).getBindableType();
|
||||
|
|
|
@ -30,7 +30,8 @@ package org.hibernate.jpa.metamodel.internal;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public enum UnsupportedFeature {
|
||||
ANY( "ANY mappings not supported in JPA metamodel" );
|
||||
ANY( "ANY mappings not supported in JPA metamodel" ),
|
||||
ARRAY( "Arrays (HBM <array/> mappings) are not supported in JPA metamodel" );
|
||||
|
||||
private final String message;
|
||||
|
||||
|
|
|
@ -321,6 +321,10 @@ public class AttributeBuilder {
|
|||
else {
|
||||
final PluralAttributeBinding pluralAttributeBinding = (PluralAttributeBinding) attributeBinding;
|
||||
|
||||
if ( pluralAttributeBinding.getAttribute().getNature() == PluralAttributeNature.ARRAY ) {
|
||||
context.handleUnsupportedFeature( UnsupportedFeature.ARRAY );
|
||||
}
|
||||
|
||||
// First, determine the type of the elements and use that to help determine the
|
||||
// collection type)
|
||||
final PluralAttributeElementBinding elementBinding = pluralAttributeBinding.getPluralAttributeElementBinding();
|
||||
|
@ -370,18 +374,6 @@ public class AttributeBuilder {
|
|||
keyPersistentAttributeType = Attribute.PersistentAttributeType.BASIC;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// for the sake of symmetry...
|
||||
if ( pluralAttributeBinding.getPluralAttributeKeyBinding() != null ) {
|
||||
throw new HibernateException(
|
||||
String.format(
|
||||
"Encountered non-Map attribute binding with associated map-key binding : %s#%s",
|
||||
jpaOwner.getJavaType().getName(),
|
||||
pluralAttributeBinding.getAttribute().getName()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return new PluralAttributeMetadataImpl(
|
||||
pluralAttributeBinding,
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|||
import org.hibernate.jpa.metamodel.internal.AbstractIdentifiableType;
|
||||
import org.hibernate.jpa.metamodel.internal.EmbeddableTypeImpl;
|
||||
import org.hibernate.jpa.metamodel.internal.EntityTypeImpl;
|
||||
import org.hibernate.jpa.metamodel.internal.JpaMetaModelPopulationSetting;
|
||||
import org.hibernate.jpa.metamodel.internal.MappedSuperclassTypeImpl;
|
||||
import org.hibernate.jpa.metamodel.internal.MetamodelImpl;
|
||||
import org.hibernate.jpa.metamodel.internal.UnsupportedFeature;
|
||||
|
@ -82,6 +83,7 @@ public class MetamodelBuilder {
|
|||
private final Map<Class<?>, MappedSuperclassTypeImpl<?>> mappedSuperclassTypeMap = new HashMap<Class<?>, MappedSuperclassTypeImpl<?>>();
|
||||
|
||||
// these fields are needed just for the duration of building the metamodel
|
||||
private final JpaMetaModelPopulationSetting populationSetting;
|
||||
private final AttributeBuilder attributeBuilder;
|
||||
private final Map<String,EntityTypeImpl> entityTypeByNameMap = new HashMap<String, EntityTypeImpl>();
|
||||
private final Map<MappedSuperclassTypeImpl,String> mappedSuperclassEntityNameMap = new HashMap<MappedSuperclassTypeImpl, String>();
|
||||
|
@ -89,8 +91,9 @@ public class MetamodelBuilder {
|
|||
private Set<Hierarchical> alreadyProcessed = new HashSet<Hierarchical>();
|
||||
|
||||
|
||||
public MetamodelBuilder(SessionFactoryImplementor sessionFactory) {
|
||||
public MetamodelBuilder(SessionFactoryImplementor sessionFactory, JpaMetaModelPopulationSetting populationSetting) {
|
||||
this.sessionFactory = sessionFactory;
|
||||
this.populationSetting = populationSetting;
|
||||
this.attributeBuilder = new AttributeBuilder( new AttributeBuilderContext() );
|
||||
}
|
||||
|
||||
|
@ -328,10 +331,18 @@ public class MetamodelBuilder {
|
|||
}
|
||||
|
||||
private void populateStaticMetamodel(AbstractIdentifiableType jpaDescriptor) {
|
||||
if ( populationSetting == JpaMetaModelPopulationSetting.DISABLED ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// todo : implement !
|
||||
}
|
||||
|
||||
private void populateStaticMetamodel(EmbeddableTypeImpl embeddable) {
|
||||
if ( populationSetting == JpaMetaModelPopulationSetting.DISABLED ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// todo : implement !
|
||||
}
|
||||
|
||||
|
@ -340,6 +351,9 @@ public class MetamodelBuilder {
|
|||
* Implementation of AttributeBuilder.Context
|
||||
*/
|
||||
class AttributeBuilderContext implements AttributeBuilder.Context {
|
||||
public AttributeBuilderContext() {
|
||||
}
|
||||
|
||||
public Type locateEntityTypeByName(String entityName) {
|
||||
return entityTypeByNameMap.get( entityName );
|
||||
}
|
||||
|
@ -379,8 +393,7 @@ public class MetamodelBuilder {
|
|||
|
||||
@Override
|
||||
public void handleUnsupportedFeature(UnsupportedFeature feature) {
|
||||
boolean ignoreUnsupported = true;
|
||||
if ( ignoreUnsupported ) {
|
||||
if ( populationSetting == JpaMetaModelPopulationSetting.IGNORE_UNSUPPORTED ) {
|
||||
log.debug( "Ignoring mapping construct not supported as part of JPA metamodel [" + feature.getMessage() + "]" );
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
|
||||
* third-party contributors as indicated by either @author tags or express
|
||||
* copyright attribution statements applied by the authors. All
|
||||
* third-party contributions are distributed under license by Red Hat Inc.
|
||||
* Copyright (c) 2012, 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
|
||||
|
|
|
@ -40,11 +40,13 @@ import org.jboss.logging.Logger;
|
|||
|
||||
import org.hibernate.annotations.common.AssertionFailure;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.mapping.Array;
|
||||
import org.hibernate.mapping.Collection;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.Map;
|
||||
import org.hibernate.mapping.OneToMany;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.PrimitiveArray;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.mapping.Value;
|
||||
import org.hibernate.tuple.entity.EntityMetamodel;
|
||||
|
@ -441,19 +443,17 @@ public class AttributeFactory {
|
|||
LOG.trace("Starting attribute metadata determination [" + attributeContext.getPropertyMapping().getName() + "]");
|
||||
final Member member = memberResolver.resolveMember( attributeContext );
|
||||
LOG.trace(" Determined member [" + member + "]");
|
||||
if ( member == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Value value = attributeContext.getPropertyMapping().getValue();
|
||||
final org.hibernate.type.Type type = value.getType();
|
||||
LOG.trace(" Determined type [name=" + type.getName() + ", class=" + type.getClass().getName() + "]");
|
||||
|
||||
if ( type.isAnyType() ) {
|
||||
// ANY mappings are currently not supported in the JPA metamodel; see HHH-6589
|
||||
if ( context.isIgnoreUnsupported() ) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException( "ANY not supported" );
|
||||
}
|
||||
context.handleAnyMapping();
|
||||
return null;
|
||||
}
|
||||
else if ( type.isAssociationType() ) {
|
||||
// collection or entity
|
||||
|
@ -466,8 +466,15 @@ public class AttributeFactory {
|
|||
determineSingularAssociationAttributeType( member )
|
||||
);
|
||||
}
|
||||
|
||||
// collection
|
||||
if (value instanceof Collection) {
|
||||
if ( Array.class.isInstance( value )
|
||||
|| PrimitiveArray.class.isInstance( value ) ) {
|
||||
context.handleArrayMapping();
|
||||
return null;
|
||||
}
|
||||
|
||||
final Collection collValue = (Collection)value;
|
||||
final Value elementValue = collValue.getElement();
|
||||
final org.hibernate.type.Type elementType = elementValue.getType();
|
||||
|
@ -476,8 +483,9 @@ public class AttributeFactory {
|
|||
// collection type)
|
||||
final Attribute.PersistentAttributeType elementPersistentAttributeType;
|
||||
final Attribute.PersistentAttributeType persistentAttributeType;
|
||||
if (elementType.isAnyType()) {
|
||||
throw new UnsupportedOperationException("collection of any not supported yet");
|
||||
if ( elementType.isAnyType() ) {
|
||||
context.handleAnyMapping();
|
||||
return null;
|
||||
}
|
||||
final boolean isManyToMany = isManyToMany(member);
|
||||
if (elementValue instanceof Component) {
|
||||
|
@ -498,15 +506,33 @@ public class AttributeFactory {
|
|||
final Value keyValue = ((Map)value).getIndex();
|
||||
final org.hibernate.type.Type keyType = keyValue.getType();
|
||||
|
||||
if (keyType.isAnyType()) throw new UnsupportedOperationException("collection of any not supported yet");
|
||||
if (keyValue instanceof Component) keyPersistentAttributeType = Attribute.PersistentAttributeType.EMBEDDED;
|
||||
else if (keyType.isAssociationType()) keyPersistentAttributeType = Attribute.PersistentAttributeType.MANY_TO_ONE;
|
||||
else keyPersistentAttributeType = Attribute.PersistentAttributeType.BASIC;
|
||||
} else keyPersistentAttributeType = null;
|
||||
return new PluralAttributeMetadataImpl(attributeContext.getPropertyMapping(), attributeContext.getOwnerType(),
|
||||
member, persistentAttributeType, elementPersistentAttributeType,
|
||||
keyPersistentAttributeType);
|
||||
} else if (value instanceof OneToMany) {
|
||||
if ( keyType.isAnyType() ) {
|
||||
context.handleAnyMapping();
|
||||
return null;
|
||||
}
|
||||
if (keyValue instanceof Component) {
|
||||
keyPersistentAttributeType = Attribute.PersistentAttributeType.EMBEDDED;
|
||||
}
|
||||
else if (keyType.isAssociationType()) {
|
||||
keyPersistentAttributeType = Attribute.PersistentAttributeType.MANY_TO_ONE;
|
||||
}
|
||||
else {
|
||||
keyPersistentAttributeType = Attribute.PersistentAttributeType.BASIC;
|
||||
}
|
||||
}
|
||||
else {
|
||||
keyPersistentAttributeType = null;
|
||||
}
|
||||
return new PluralAttributeMetadataImpl(
|
||||
attributeContext.getPropertyMapping(),
|
||||
attributeContext.getOwnerType(),
|
||||
member,
|
||||
persistentAttributeType,
|
||||
elementPersistentAttributeType,
|
||||
keyPersistentAttributeType
|
||||
);
|
||||
}
|
||||
else if (value instanceof OneToMany) {
|
||||
// TODO : is this even possible??? Really OneToMany should be describing the
|
||||
// element value within a o.h.mapping.Collection (see logic branch above)
|
||||
throw new IllegalArgumentException("HUH???");
|
||||
|
@ -878,9 +904,7 @@ public class AttributeFactory {
|
|||
}
|
||||
|
||||
private final MemberResolver EMBEDDED_MEMBER_RESOLVER = new MemberResolver() {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Member resolveMember(AttributeContext attributeContext) {
|
||||
final EmbeddableTypeImpl embeddableType = ( EmbeddableTypeImpl<?> ) attributeContext.getOwnerType();
|
||||
final String attributeName = attributeContext.getPropertyMapping().getName();
|
||||
|
@ -893,21 +917,23 @@ public class AttributeFactory {
|
|||
|
||||
|
||||
private final MemberResolver VIRTUAL_IDENTIFIER_MEMBER_RESOLVER = new MemberResolver() {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Member resolveMember(AttributeContext attributeContext) {
|
||||
final IdentifiableType identifiableType = (IdentifiableType) attributeContext.getOwnerType();
|
||||
final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( identifiableType );
|
||||
if ( entityMetamodel == null ) {
|
||||
// this happens with badly written custom persisters, like the ones in our test suite :)
|
||||
return null;
|
||||
}
|
||||
if ( ! entityMetamodel.getIdentifierProperty().isVirtual() ) {
|
||||
throw new IllegalArgumentException( "expecting IdClass mapping" );
|
||||
}
|
||||
org.hibernate.type.Type type = entityMetamodel.getIdentifierProperty().getType();
|
||||
if ( ! EmbeddedComponentType.class.isInstance( type ) ) {
|
||||
if ( ! ComponentType.class.isInstance( type ) ) {
|
||||
throw new IllegalArgumentException( "expecting IdClass mapping" );
|
||||
}
|
||||
|
||||
final EmbeddedComponentType componentType = (EmbeddedComponentType) type;
|
||||
final ComponentType componentType = (ComponentType) type;
|
||||
final String attributeName = attributeContext.getPropertyMapping().getName();
|
||||
return componentType.getComponentTuplizer()
|
||||
.getGetter( componentType.getPropertyIndex( attributeName ) )
|
||||
|
@ -919,9 +945,7 @@ public class AttributeFactory {
|
|||
* A {@link java.lang.reflect.Member} resolver for normal attributes.
|
||||
*/
|
||||
private final MemberResolver NORMAL_MEMBER_RESOLVER = new MemberResolver() {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Member resolveMember(AttributeContext attributeContext) {
|
||||
final AbstractManagedType ownerType = attributeContext.getOwnerType();
|
||||
final Property property = attributeContext.getPropertyMapping();
|
||||
|
@ -933,6 +957,10 @@ public class AttributeFactory {
|
|||
|| Type.PersistenceType.MAPPED_SUPERCLASS == persistenceType ) {
|
||||
final IdentifiableType identifiableType = (IdentifiableType) ownerType;
|
||||
final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( identifiableType );
|
||||
if ( entityMetamodel == null ) {
|
||||
// this happens with badly written custom persisters, like the ones in our test suite :)
|
||||
return null;
|
||||
}
|
||||
final String propertyName = property.getName();
|
||||
final Integer index = entityMetamodel.getPropertyIndexOrNull( propertyName );
|
||||
if ( index == null ) {
|
||||
|
@ -952,9 +980,14 @@ public class AttributeFactory {
|
|||
};
|
||||
|
||||
private final MemberResolver IDENTIFIER_MEMBER_RESOLVER = new MemberResolver() {
|
||||
@Override
|
||||
public Member resolveMember(AttributeContext attributeContext) {
|
||||
final IdentifiableType identifiableType = (IdentifiableType) attributeContext.getOwnerType();
|
||||
final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( identifiableType );
|
||||
if ( entityMetamodel == null ) {
|
||||
// this happens with badly written custom persisters, like the ones in our test suite :)
|
||||
return null;
|
||||
}
|
||||
if ( ! attributeContext.getPropertyMapping().getName()
|
||||
.equals( entityMetamodel.getIdentifierProperty().getName() ) ) {
|
||||
// this *should* indicate processing part of an IdClass...
|
||||
|
@ -965,9 +998,14 @@ public class AttributeFactory {
|
|||
};
|
||||
|
||||
private final MemberResolver VERSION_MEMBER_RESOLVER = new MemberResolver() {
|
||||
@Override
|
||||
public Member resolveMember(AttributeContext attributeContext) {
|
||||
final IdentifiableType identifiableType = (IdentifiableType) attributeContext.getOwnerType();
|
||||
final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( identifiableType );
|
||||
if ( entityMetamodel == null ) {
|
||||
// this happens with badly written custom persisters, like the ones in our test suite :)
|
||||
return null;
|
||||
}
|
||||
final String versionPropertyName = attributeContext.getPropertyMapping().getName();
|
||||
if ( ! versionPropertyName.equals( entityMetamodel.getVersionProperty().getName() ) ) {
|
||||
// this should never happen, but to be safe...
|
||||
|
|
|
@ -196,6 +196,14 @@ class MetadataContext {
|
|||
LOG.trace("Starting entity [" + safeMapping.getEntityName() + "]");
|
||||
try {
|
||||
final EntityTypeImpl<?> jpa2Mapping = entityTypesByPersistentClass.get( safeMapping );
|
||||
if ( ! safeMapping.getEntityName().equals( jpa2Mapping.getJavaType().getName() ) ) {
|
||||
// skip it
|
||||
continue;
|
||||
}
|
||||
if ( sessionFactory.getEntityPersister( safeMapping.getEntityName() ).getEntityMetamodel() == null ) {
|
||||
// skip it
|
||||
continue;
|
||||
}
|
||||
applyIdMetadata( safeMapping, jpa2Mapping );
|
||||
applyVersionAttribute( safeMapping, jpa2Mapping );
|
||||
Iterator<Property> properties = safeMapping.getDeclaredPropertyIterator();
|
||||
|
@ -482,4 +490,21 @@ class MetadataContext {
|
|||
}
|
||||
return persistentClass;
|
||||
}
|
||||
|
||||
public void handleAnyMapping() {
|
||||
// ANY mappings are currently not supported in the JPA metamodel; see HHH-6589
|
||||
if ( isIgnoreUnsupported() ) {
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException( "ANY not supported" );
|
||||
}
|
||||
}
|
||||
|
||||
public void handleArrayMapping() {
|
||||
if ( isIgnoreUnsupported() ) {
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException( "Arrays not supported" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,6 +74,10 @@ public class Property implements Serializable, MetaAttributable {
|
|||
* @return True if synthetic; false otherwise.
|
||||
*/
|
||||
public boolean isSynthetic() {
|
||||
//noinspection SimplifiableIfStatement
|
||||
if ( isComposite() ) {
|
||||
return ( (Component) value ).isEmbedded();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.util.Set;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public enum PluralAttributeNature {
|
||||
ARRAY( "array", Object[].class ),
|
||||
BAG( "bag", Collection.class ),
|
||||
IDBAG( "idbag", Collection.class ),
|
||||
SET( "set", Set.class ),
|
||||
|
@ -47,7 +48,9 @@ public enum PluralAttributeNature {
|
|||
PluralAttributeNature(String name, Class javaContract) {
|
||||
this.name = name;
|
||||
this.javaContract = javaContract;
|
||||
this.indexed = Map.class.isAssignableFrom( javaContract ) || List.class.isAssignableFrom( javaContract );
|
||||
this.indexed = Map.class.isAssignableFrom( javaContract )
|
||||
|| List.class.isAssignableFrom( javaContract )
|
||||
|| javaContract.isArray();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
|
|
@ -25,7 +25,6 @@ package org.hibernate.jpa.boot.spi;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
@ -99,7 +98,7 @@ public class JpaUnifiedSettingsBuilder {
|
|||
}
|
||||
|
||||
private static class ResultImpl implements Result {
|
||||
private final Map<?,?> settings = new ConcurrentHashMap();
|
||||
private final Map settings = new ConcurrentHashMap();
|
||||
private final CfgXmlMappingArtifactsImpl cfgXmlMappingArtifacts = new CfgXmlMappingArtifactsImpl();
|
||||
|
||||
@Override
|
||||
|
@ -118,8 +117,8 @@ public class JpaUnifiedSettingsBuilder {
|
|||
PersistenceUnitDescriptor persistenceUnit,
|
||||
Map integrationSettings,
|
||||
final BootstrapServiceRegistry bootstrapServiceRegistry) {
|
||||
final Map merged = new HashMap();
|
||||
// first, apply persistence.xml-defined settings
|
||||
final Map merged = new HashMap();
|
||||
if ( persistenceUnit.getProperties() != null ) {
|
||||
merged.putAll( persistenceUnit.getProperties() );
|
||||
}
|
||||
|
@ -174,12 +173,13 @@ public class JpaUnifiedSettingsBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
// was getting NPE exceptions from the underlying map when just using #putAll, so going this safer route...
|
||||
Iterator itr = merged.entrySet().iterator();
|
||||
while ( itr.hasNext() ) {
|
||||
final Map.Entry entry = (Map.Entry) itr.next();
|
||||
if ( entry.getValue() == null ) {
|
||||
itr.remove();
|
||||
applyAllNonNull( merged );
|
||||
}
|
||||
|
||||
private void applyAllNonNull(Map<?,?> values) {
|
||||
for ( Map.Entry entry : values.entrySet() ) {
|
||||
if ( entry.getValue() != null ) {
|
||||
settings.put( entry.getKey(), entry.getValue() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ import java.io.ObjectOutputStream;
|
|||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
@ -59,15 +58,11 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|||
import org.hibernate.id.IdentifierGenerator;
|
||||
import org.hibernate.id.UUIDGenerator;
|
||||
import org.hibernate.internal.SessionFactoryImpl;
|
||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.HibernateQuery;
|
||||
import org.hibernate.jpa.boot.internal.SettingsImpl;
|
||||
import org.hibernate.jpa.criteria.CriteriaBuilderImpl;
|
||||
import org.hibernate.jpa.metamodel.internal.JpaMetaModelPopulationSetting;
|
||||
import org.hibernate.jpa.metamodel.internal.legacy.MetamodelImpl;
|
||||
import org.hibernate.jpa.internal.util.PersistenceUtilHelper;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.metadata.ClassMetadata;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
|
|
|
@ -70,19 +70,19 @@ public interface EntityManagerMessageLogger extends CoreMessageLogger {
|
|||
@Message( value = "Exploded jar file not a directory (ignored): %s", id = 15006 )
|
||||
void explodedJarNotDirectory( URL jarUrl );
|
||||
|
||||
/**
|
||||
* Simply deprecated for now to show the fact that id 15007 is still in use...
|
||||
*
|
||||
* @deprecated Moved to hibernate-core in conjunction with moving JPA metamodel generation to SessionFactory
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
@LogMessage( level = ERROR )
|
||||
@Message( value = "Illegal argument on static metamodel field injection : %s#%s; expected type : %s; encountered type : %s", id = 15007 )
|
||||
void illegalArgumentOnStaticMetamodelFieldInjection( String metamodelClassName,
|
||||
String attributeName,
|
||||
String attributeJavaType,
|
||||
String metamodelFieldJavaType );
|
||||
// /**
|
||||
// * Simply deprecated for now to show the fact that id 15007 is still in use...
|
||||
// *
|
||||
// * @deprecated Moved to hibernate-core in conjunction with moving JPA metamodel generation to SessionFactory
|
||||
// */
|
||||
// @Override
|
||||
// @Deprecated
|
||||
// @LogMessage( level = ERROR )
|
||||
// @Message( value = "Illegal argument on static metamodel field injection : %s#%s; expected type : %s; encountered type : %s", id = 15007 )
|
||||
// void illegalArgumentOnStaticMetamodelFieldInjection( String metamodelClassName,
|
||||
// String attributeName,
|
||||
// String attributeJavaType,
|
||||
// String metamodelFieldJavaType );
|
||||
|
||||
@LogMessage( level = ERROR )
|
||||
@Message( value = "Malformed URL: %s", id = 15008 )
|
||||
|
@ -99,17 +99,17 @@ public interface EntityManagerMessageLogger extends CoreMessageLogger {
|
|||
void unableToFindFile( URL jarUrl,
|
||||
@Cause Exception e );
|
||||
|
||||
/**
|
||||
* Simply deprecated for now to show the fact that id 15011 is still in use...
|
||||
*
|
||||
* @deprecated Moved to hibernate-core in conjunction with moving JPA metamodel generation to SessionFactory
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
@LogMessage( level = ERROR )
|
||||
@Message( value = "Unable to locate static metamodel field : %s#%s", id = 15011 )
|
||||
void unableToLocateStaticMetamodelField( String metamodelClassName,
|
||||
String attributeName );
|
||||
// /**
|
||||
// * Simply deprecated for now to show the fact that id 15011 is still in use...
|
||||
// *
|
||||
// * @deprecated Moved to hibernate-core in conjunction with moving JPA metamodel generation to SessionFactory
|
||||
// */
|
||||
// @Override
|
||||
// @Deprecated
|
||||
// @LogMessage( level = ERROR )
|
||||
// @Message( value = "Unable to locate static metamodel field : %s#%s", id = 15011 )
|
||||
// void unableToLocateStaticMetamodelField( String metamodelClassName,
|
||||
// String attributeName );
|
||||
|
||||
@LogMessage( level = INFO )
|
||||
@Message( value = "Using provided datasource", id = 15012 )
|
||||
|
|
Loading…
Reference in New Issue