Re-add AvailableSettings.JPA_METAMODEL_GENERATION and re-enable metamodel tests
This commit is contained in:
parent
195df69019
commit
1184a5963b
|
@ -1118,6 +1118,15 @@ XML configuration file to use to configure Hibernate.
|
||||||
If true, the persistence context will be discarded (think `clear()` when the method is called).
|
If true, the persistence context will be discarded (think `clear()` when the method is called).
|
||||||
Otherwise, the persistence context will stay alive till the transaction completion: all objects will remain managed, and any change will be synchronized with the database (default to false, ie wait for transaction completion).
|
Otherwise, the persistence context will stay alive till the transaction completion: all objects will remain managed, and any change will be synchronized with the database (default to false, ie wait for transaction completion).
|
||||||
|
|
||||||
|
`*hibernate.ejb.metamodel.population*` (e.g. `enabled` or `disabled`, or `ignoreUnsupported` (default value))::
|
||||||
|
Setting that indicates whether to build the Jakarta Persistence types.
|
||||||
|
+
|
||||||
|
Accepts three values:
|
||||||
|
+
|
||||||
|
enabled::: Do the build.
|
||||||
|
disabled::: Do not do the build.
|
||||||
|
ignoreUnsupported::: Do the build, but ignore any non-Jakarta Persistence features that would otherwise result in a failure (e.g. `@Any` annotation).
|
||||||
|
|
||||||
`*hibernate.jpa.static_metamodel.population*` (e.g. `enabled` or `disabled`, or `skipUnsupported` (default value))::
|
`*hibernate.jpa.static_metamodel.population*` (e.g. `enabled` or `disabled`, or `skipUnsupported` (default value))::
|
||||||
Setting that controls whether we seek out Jakarta Persistence _static metamodel_ classes and populate them.
|
Setting that controls whether we seek out Jakarta Persistence _static metamodel_ classes and populate them.
|
||||||
+
|
+
|
||||||
|
|
|
@ -235,6 +235,23 @@ public interface AvailableSettings {
|
||||||
*/
|
*/
|
||||||
String TC_CLASSLOADER = "hibernate.classLoader.tccl_lookup_precedence";
|
String TC_CLASSLOADER = "hibernate.classLoader.tccl_lookup_precedence";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setting that indicates whether to build the JPA types. Accepts
|
||||||
|
* 3 values:<ul>
|
||||||
|
* <li>
|
||||||
|
* <b>enabled</b> - Do the build
|
||||||
|
* </li>
|
||||||
|
* <li>
|
||||||
|
* <b>disabled</b> - Do not do the build
|
||||||
|
* </li>
|
||||||
|
* <li>
|
||||||
|
* <b>ignoreUnsupported</b> - Do the build, but ignore any non-JPA features that would otherwise
|
||||||
|
* result in a failure.
|
||||||
|
* </li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
String JPA_METAMODEL_POPULATION = "hibernate.jpa.metamodel.population";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setting that controls whether we seek out JPA "static metamodel" classes and populate them. Accepts
|
* Setting that controls whether we seek out JPA "static metamodel" classes and populate them. Accepts
|
||||||
* 3 values:<ul>
|
* 3 values:<ul>
|
||||||
|
|
|
@ -239,7 +239,7 @@ public class AttributeFactory {
|
||||||
final EmbeddableTypeImpl<Y> embeddableType;
|
final EmbeddableTypeImpl<Y> embeddableType;
|
||||||
|
|
||||||
if ( component.isDynamic() ) {
|
if ( component.isDynamic() ) {
|
||||||
final JavaType javaTypeDescriptor = context.getJavaTypeDescriptorRegistry().getDescriptor( Map.class );
|
final JavaType javaTypeDescriptor = context.getJavaTypeDescriptorRegistry().getDescriptor( java.util.Map.class );
|
||||||
|
|
||||||
embeddableType = new EmbeddableTypeImpl<>(
|
embeddableType = new EmbeddableTypeImpl<>(
|
||||||
javaTypeDescriptor,
|
javaTypeDescriptor,
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/
|
||||||
|
package org.hibernate.metamodel.internal;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public enum JpaMetaModelPopulationSetting {
|
||||||
|
ENABLED,
|
||||||
|
DISABLED,
|
||||||
|
IGNORE_UNSUPPORTED;
|
||||||
|
|
||||||
|
public static JpaMetaModelPopulationSetting parse(String setting) {
|
||||||
|
if ( "enabled".equalsIgnoreCase( setting ) ) {
|
||||||
|
return ENABLED;
|
||||||
|
}
|
||||||
|
else if ( "disabled".equalsIgnoreCase( setting ) ) {
|
||||||
|
return DISABLED;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return IGNORE_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JpaMetaModelPopulationSetting determineJpaMetaModelPopulationSetting(Map configurationValues) {
|
||||||
|
String setting = ConfigurationHelper.getString(
|
||||||
|
AvailableSettings.JPA_METAMODEL_POPULATION,
|
||||||
|
configurationValues
|
||||||
|
);
|
||||||
|
return JpaMetaModelPopulationSetting.parse( setting );
|
||||||
|
}
|
||||||
|
}
|
|
@ -46,7 +46,7 @@ public enum JpaStaticMetaModelPopulationSetting {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JpaStaticMetaModelPopulationSetting determineJpaMetaModelPopulationSetting(Map configurationValues) {
|
public static JpaStaticMetaModelPopulationSetting determineJpaStaticMetaModelPopulationSetting(Map configurationValues) {
|
||||||
return parse( determineSetting( configurationValues ) );
|
return parse( determineSetting( configurationValues ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,30 +75,30 @@ public class MetadataContext {
|
||||||
private final JpaMetamodel jpaMetamodel;
|
private final JpaMetamodel jpaMetamodel;
|
||||||
private final RuntimeModelCreationContext runtimeModelCreationContext;
|
private final RuntimeModelCreationContext runtimeModelCreationContext;
|
||||||
|
|
||||||
private Set<MappedSuperclass> knownMappedSuperclasses;
|
private final Set<MappedSuperclass> knownMappedSuperclasses;
|
||||||
private TypeConfiguration typeConfiguration;
|
private final TypeConfiguration typeConfiguration;
|
||||||
private final JpaStaticMetaModelPopulationSetting jpaStaticMetaModelPopulationSetting;
|
private final JpaStaticMetaModelPopulationSetting jpaStaticMetaModelPopulationSetting;
|
||||||
private final AttributeFactory attributeFactory = new AttributeFactory( this );
|
private final AttributeFactory attributeFactory = new AttributeFactory( this );
|
||||||
|
|
||||||
private Map<Class<?>, EntityDomainType<?>> entityTypes = new HashMap<>();
|
private final Map<Class<?>, EntityDomainType<?>> entityTypes = new HashMap<>();
|
||||||
private Map<String, EntityDomainType<?>> entityTypesByEntityName = new HashMap<>();
|
private final Map<String, EntityDomainType<?>> entityTypesByEntityName = new HashMap<>();
|
||||||
private Map<PersistentClass, EntityDomainType<?>> entityTypesByPersistentClass = new HashMap<>();
|
private final Map<PersistentClass, EntityDomainType<?>> entityTypesByPersistentClass = new HashMap<>();
|
||||||
|
|
||||||
private Map<Class, EmbeddableDomainType<?>> embeddables = new HashMap<>();
|
private final Map<Class<?>, EmbeddableDomainType<?>> embeddables = new HashMap<>();
|
||||||
private Map<Class, List<EmbeddableDomainType<?>>> embeddablesToProcess = new HashMap<>();
|
private final Map<Class<?>, List<EmbeddableDomainType<?>>> embeddablesToProcess = new HashMap<>();
|
||||||
private Map<EmbeddableDomainType<?>, Component> componentByEmbeddable = new HashMap<>();
|
private final Map<EmbeddableDomainType<?>, Component> componentByEmbeddable = new HashMap<>();
|
||||||
|
|
||||||
private Map<MappedSuperclass, MappedSuperclassDomainType<?>> mappedSuperclassByMappedSuperclassMapping = new HashMap<>();
|
private final Map<MappedSuperclass, MappedSuperclassDomainType<?>> mappedSuperclassByMappedSuperclassMapping = new HashMap<>();
|
||||||
private Map<MappedSuperclassDomainType<?>, PersistentClass> mappedSuperClassTypeToPersistentClass = new HashMap<>();
|
private final Map<MappedSuperclassDomainType<?>, PersistentClass> mappedSuperClassTypeToPersistentClass = new HashMap<>();
|
||||||
|
|
||||||
//this list contains MappedSuperclass and EntityTypes ordered by superclass first
|
//this list contains MappedSuperclass and EntityTypes ordered by superclass first
|
||||||
private List<Object> orderedMappings = new ArrayList<>();
|
private final List<Object> orderedMappings = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stack of PersistentClass being processed. Last in the list is the highest in the stack.
|
* Stack of PersistentClass being processed. Last in the list is the highest in the stack.
|
||||||
*/
|
*/
|
||||||
private List<PersistentClass> stackOfPersistentClassesBeingProcessed = new ArrayList<>();
|
private final List<PersistentClass> stackOfPersistentClassesBeingProcessed = new ArrayList<>();
|
||||||
private MappingMetamodel metamodel;
|
private final MappingMetamodel metamodel;
|
||||||
|
|
||||||
public MetadataContext(
|
public MetadataContext(
|
||||||
JpaMetamodel jpaMetamodel,
|
JpaMetamodel jpaMetamodel,
|
||||||
|
@ -144,7 +144,7 @@ public class MetadataContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<EmbeddableDomainType<?>> getEmbeddableTypeSet() {
|
public Set<EmbeddableDomainType<?>> getEmbeddableTypeSet() {
|
||||||
return new HashSet<>( embeddables.values() );
|
return componentByEmbeddable.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Class<?>, MappedSuperclassDomainType<?>> getMappedSuperclassTypeMap() {
|
public Map<Class<?>, MappedSuperclassDomainType<?>> getMappedSuperclassTypeMap() {
|
||||||
|
@ -153,7 +153,7 @@ public class MetadataContext {
|
||||||
mappedSuperclassByMappedSuperclassMapping.size()
|
mappedSuperclassByMappedSuperclassMapping.size()
|
||||||
);
|
);
|
||||||
|
|
||||||
for ( MappedSuperclassDomainType mappedSuperclassType : mappedSuperclassByMappedSuperclassMapping.values() ) {
|
for ( MappedSuperclassDomainType<?> mappedSuperclassType : mappedSuperclassByMappedSuperclassMapping.values() ) {
|
||||||
mappedSuperClassTypeMap.put(
|
mappedSuperClassTypeMap.put(
|
||||||
mappedSuperclassType.getJavaType(),
|
mappedSuperclassType.getJavaType(),
|
||||||
mappedSuperclassType
|
mappedSuperclassType
|
||||||
|
@ -164,7 +164,7 @@ public class MetadataContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerEntityType(PersistentClass persistentClass, EntityTypeImpl<?> entityType) {
|
public void registerEntityType(PersistentClass persistentClass, EntityTypeImpl<?> entityType) {
|
||||||
if ( entityType.getBindableJavaType() != null ) {
|
if ( entityType.getBindableJavaType() != null && entityType.getBindableJavaType() != Map.class ) {
|
||||||
entityTypes.put( entityType.getBindableJavaType(), entityType );
|
entityTypes.put( entityType.getBindableJavaType(), entityType );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ public class MetadataContext {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unchecked", "WeakerAccess"})
|
@SuppressWarnings({"unchecked", "WeakerAccess"})
|
||||||
public <E> EntityDomainType<E> locateEntityType(String entityName) {
|
public <E> EntityDomainType<E> locateEntityType(String entityName) {
|
||||||
return (EntityDomainType) entityTypesByEntityName.get( entityName );
|
return (EntityDomainType<E>) entityTypesByEntityName.get( entityName );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
|
@ -264,7 +264,7 @@ public class MetadataContext {
|
||||||
LOG.trace( "Starting entity [" + safeMapping.getEntityName() + ']' );
|
LOG.trace( "Starting entity [" + safeMapping.getEntityName() + ']' );
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final EntityDomainType<?> jpaMapping = entityTypesByPersistentClass.get( safeMapping );
|
final EntityDomainType<Object> jpaMapping = (EntityDomainType<Object>) entityTypesByPersistentClass.get( safeMapping );
|
||||||
|
|
||||||
applyIdMetadata( safeMapping, jpaMapping );
|
applyIdMetadata( safeMapping, jpaMapping );
|
||||||
applyVersionAttribute( safeMapping, jpaMapping );
|
applyVersionAttribute( safeMapping, jpaMapping );
|
||||||
|
@ -282,16 +282,16 @@ public class MetadataContext {
|
||||||
// skip the version property, it was already handled previously.
|
// skip the version property, it was already handled previously.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final PersistentAttribute attribute = attributeFactory.buildAttribute(
|
final PersistentAttribute<Object, ?> attribute = attributeFactory.buildAttribute(
|
||||||
jpaMapping,
|
jpaMapping,
|
||||||
property
|
property
|
||||||
);
|
);
|
||||||
if ( attribute != null ) {
|
if ( attribute != null ) {
|
||||||
( (AttributeContainer) jpaMapping ).getInFlightAccess().addAttribute( attribute );
|
( (AttributeContainer<Object>) jpaMapping ).getInFlightAccess().addAttribute( attribute );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
( (AttributeContainer) jpaMapping ).getInFlightAccess().finishUp();
|
( (AttributeContainer<?>) jpaMapping ).getInFlightAccess().finishUp();
|
||||||
|
|
||||||
if ( staticMetamodelScanEnabled ) {
|
if ( staticMetamodelScanEnabled ) {
|
||||||
populateStaticMetamodel( jpaMapping );
|
populateStaticMetamodel( jpaMapping );
|
||||||
|
@ -309,7 +309,7 @@ public class MetadataContext {
|
||||||
LOG.trace( "Starting mapped superclass [" + safeMapping.getMappedClass().getName() + ']' );
|
LOG.trace( "Starting mapped superclass [" + safeMapping.getMappedClass().getName() + ']' );
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final MappedSuperclassDomainType<?> jpaType = mappedSuperclassByMappedSuperclassMapping.get( safeMapping );
|
final MappedSuperclassDomainType<Object> jpaType = (MappedSuperclassDomainType<Object>) mappedSuperclassByMappedSuperclassMapping.get( safeMapping );
|
||||||
|
|
||||||
applyIdMetadata( safeMapping, jpaType );
|
applyIdMetadata( safeMapping, jpaType );
|
||||||
applyVersionAttribute( safeMapping, jpaType );
|
applyVersionAttribute( safeMapping, jpaType );
|
||||||
|
@ -321,13 +321,13 @@ public class MetadataContext {
|
||||||
// skip the version property, it was already handled previously.
|
// skip the version property, it was already handled previously.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final PersistentAttribute attribute = attributeFactory.buildAttribute( jpaType, property );
|
final PersistentAttribute<Object, ?> attribute = attributeFactory.buildAttribute( jpaType, property );
|
||||||
if ( attribute != null ) {
|
if ( attribute != null ) {
|
||||||
( (AttributeContainer) jpaType ).getInFlightAccess().addAttribute( attribute );
|
( (AttributeContainer<Object>) jpaType ).getInFlightAccess().addAttribute( attribute );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
( (AttributeContainer) jpaType ).getInFlightAccess().finishUp();
|
( (AttributeContainer<?>) jpaType ).getInFlightAccess().finishUp();
|
||||||
|
|
||||||
if ( staticMetamodelScanEnabled ) {
|
if ( staticMetamodelScanEnabled ) {
|
||||||
populateStaticMetamodel( jpaType );
|
populateStaticMetamodel( jpaType );
|
||||||
|
@ -358,13 +358,13 @@ public class MetadataContext {
|
||||||
final Iterator<Property> propertyItr = component.getPropertyIterator();
|
final Iterator<Property> propertyItr = component.getPropertyIterator();
|
||||||
while ( propertyItr.hasNext() ) {
|
while ( propertyItr.hasNext() ) {
|
||||||
final Property property = propertyItr.next();
|
final Property property = propertyItr.next();
|
||||||
final PersistentAttribute attribute = attributeFactory.buildAttribute( embeddable, property );
|
final PersistentAttribute<Object, ?> attribute = attributeFactory.buildAttribute( (ManagedDomainType<Object>) embeddable, property );
|
||||||
if ( attribute != null ) {
|
if ( attribute != null ) {
|
||||||
( ( AttributeContainer) embeddable ).getInFlightAccess().addAttribute( attribute );
|
( ( AttributeContainer<Object>) embeddable ).getInFlightAccess().addAttribute( attribute );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
( ( AttributeContainer) embeddable ).getInFlightAccess().finishUp();
|
( ( AttributeContainer<?>) embeddable ).getInFlightAccess().finishUp();
|
||||||
embeddables.put( embeddable.getJavaType(), embeddable );
|
embeddables.put( embeddable.getJavaType(), embeddable );
|
||||||
|
|
||||||
if ( staticMetamodelScanEnabled ) {
|
if ( staticMetamodelScanEnabled ) {
|
||||||
|
@ -516,7 +516,7 @@ public class MetadataContext {
|
||||||
}
|
}
|
||||||
final String metamodelClassName = managedTypeClass.getName() + '_';
|
final String metamodelClassName = managedTypeClass.getName() + '_';
|
||||||
try {
|
try {
|
||||||
final Class metamodelClass = Class.forName( metamodelClassName, true, managedTypeClass.getClassLoader() );
|
final Class<?> metamodelClass = Class.forName( metamodelClassName, true, managedTypeClass.getClassLoader() );
|
||||||
// we found the class; so populate it...
|
// we found the class; so populate it...
|
||||||
registerAttributes( metamodelClass, managedType );
|
registerAttributes( metamodelClass, managedType );
|
||||||
}
|
}
|
||||||
|
@ -532,9 +532,9 @@ public class MetadataContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Set<Class> processedMetamodelClasses = new HashSet<>();
|
private final Set<Class<?>> processedMetamodelClasses = new HashSet<>();
|
||||||
|
|
||||||
private <X> void registerAttributes(Class metamodelClass, ManagedDomainType<X> managedType) {
|
private <X> void registerAttributes(Class<?> metamodelClass, ManagedDomainType<X> managedType) {
|
||||||
if ( !processedMetamodelClasses.add( metamodelClass ) ) {
|
if ( !processedMetamodelClasses.add( metamodelClass ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -564,7 +564,7 @@ public class MetadataContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private <X> void registerAttribute(Class metamodelClass, Attribute<X, ?> attribute) {
|
private <X> void registerAttribute(Class<?> metamodelClass, Attribute<X, ?> attribute) {
|
||||||
final String name = attribute.getName();
|
final String name = attribute.getName();
|
||||||
try {
|
try {
|
||||||
// there is a shortcoming in the existing Hibernate code in terms of the way MappedSuperclass
|
// there is a shortcoming in the existing Hibernate code in terms of the way MappedSuperclass
|
||||||
|
@ -667,7 +667,7 @@ public class MetadataContext {
|
||||||
|
|
||||||
public <J> BasicDomainType<J> resolveBasicType(Class<J> javaType) {
|
public <J> BasicDomainType<J> resolveBasicType(Class<J> javaType) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return (BasicDomainType) basicDomainTypeMap.computeIfAbsent(
|
return (BasicDomainType<J>) basicDomainTypeMap.computeIfAbsent(
|
||||||
javaType,
|
javaType,
|
||||||
jt -> {
|
jt -> {
|
||||||
final JavaTypeRegistry registry =
|
final JavaTypeRegistry registry =
|
||||||
|
|
|
@ -92,7 +92,7 @@ public abstract class AbstractManagedType<J>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void visitAttributes(Consumer<PersistentAttribute<J, ?>> action) {
|
public void visitAttributes(Consumer<? super PersistentAttribute<J, ?>> action) {
|
||||||
visitDeclaredAttributes( action );
|
visitDeclaredAttributes( action );
|
||||||
if ( getSuperType() != null ) {
|
if ( getSuperType() != null ) {
|
||||||
getSuperType().visitAttributes( (Consumer) action );
|
getSuperType().visitAttributes( (Consumer) action );
|
||||||
|
@ -100,7 +100,7 @@ public abstract class AbstractManagedType<J>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitDeclaredAttributes(Consumer<PersistentAttribute<J, ?>> action) {
|
public void visitDeclaredAttributes(Consumer<? super PersistentAttribute<J, ?>> action) {
|
||||||
declaredSingularAttributes.values().forEach( action );
|
declaredSingularAttributes.values().forEach( action );
|
||||||
if ( declaredPluralAttributes != null ) {
|
if ( declaredPluralAttributes != null ) {
|
||||||
declaredPluralAttributes.values().forEach( action );
|
declaredPluralAttributes.values().forEach( action );
|
||||||
|
|
|
@ -63,32 +63,18 @@ public interface JpaMetamodel extends jakarta.persistence.metamodel.Metamodel {
|
||||||
*/
|
*/
|
||||||
<X> EntityDomainType<X> resolveHqlEntityReference(String entityName);
|
<X> EntityDomainType<X> resolveHqlEntityReference(String entityName);
|
||||||
|
|
||||||
/**
|
|
||||||
* Visitation over all managed types via Consumer
|
|
||||||
*/
|
|
||||||
void visitManagedTypes(Consumer<ManagedDomainType<?>> action);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as {@link #managedType} except {@code null} is returned rather
|
* Same as {@link #managedType} except {@code null} is returned rather
|
||||||
* than throwing an exception
|
* than throwing an exception
|
||||||
*/
|
*/
|
||||||
<X> ManagedDomainType<X> findManagedType(Class<X> cls);
|
<X> ManagedDomainType<X> findManagedType(Class<X> cls);
|
||||||
|
|
||||||
/**
|
|
||||||
* Visitation over all entity types via Consumer
|
|
||||||
*/
|
|
||||||
void visitEntityTypes(Consumer<EntityDomainType<?>> action);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as {@link #entity} except {@code null} is returned rather
|
* Same as {@link #entity} except {@code null} is returned rather
|
||||||
* than throwing an exception
|
* than throwing an exception
|
||||||
*/
|
*/
|
||||||
<X> EntityDomainType<X> findEntityType(Class<X> cls);
|
<X> EntityDomainType<X> findEntityType(Class<X> cls);
|
||||||
|
|
||||||
void visitRootEntityTypes(Consumer<EntityDomainType<?>> action);
|
|
||||||
|
|
||||||
void visitEmbeddables(Consumer<EmbeddableDomainType<?>> action);
|
|
||||||
|
|
||||||
String qualifyImportableName(String queryName);
|
String qualifyImportableName(String queryName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,8 +41,8 @@ public interface ManagedDomainType<J> extends AllowableParameterType<J>, Managed
|
||||||
|
|
||||||
void addSubType(ManagedDomainType subType);
|
void addSubType(ManagedDomainType subType);
|
||||||
|
|
||||||
void visitAttributes(Consumer<PersistentAttribute<J,?>> action);
|
void visitAttributes(Consumer<? super PersistentAttribute<J, ?>> action);
|
||||||
void visitDeclaredAttributes(Consumer<PersistentAttribute<J,?>> action);
|
void visitDeclaredAttributes(Consumer<? super PersistentAttribute<J, ?>> action);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
PersistentAttribute<? super J,?> getAttribute(String name);
|
PersistentAttribute<? super J,?> getAttribute(String name);
|
||||||
|
|
|
@ -17,7 +17,6 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentSkipListMap;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import jakarta.persistence.EntityGraph;
|
import jakarta.persistence.EntityGraph;
|
||||||
|
@ -42,11 +41,11 @@ import org.hibernate.graph.spi.SubGraphImplementor;
|
||||||
import org.hibernate.internal.EntityManagerMessageLogger;
|
import org.hibernate.internal.EntityManagerMessageLogger;
|
||||||
import org.hibernate.internal.HEMLogging;
|
import org.hibernate.internal.HEMLogging;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
|
||||||
import org.hibernate.jpa.spi.JpaCompliance;
|
import org.hibernate.jpa.spi.JpaCompliance;
|
||||||
import org.hibernate.mapping.MappedSuperclass;
|
import org.hibernate.mapping.MappedSuperclass;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.metamodel.MappingMetamodel;
|
import org.hibernate.metamodel.MappingMetamodel;
|
||||||
|
import org.hibernate.metamodel.internal.JpaMetaModelPopulationSetting;
|
||||||
import org.hibernate.metamodel.internal.JpaStaticMetaModelPopulationSetting;
|
import org.hibernate.metamodel.internal.JpaStaticMetaModelPopulationSetting;
|
||||||
import org.hibernate.metamodel.internal.MetadataContext;
|
import org.hibernate.metamodel.internal.MetadataContext;
|
||||||
import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
|
import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
|
||||||
|
@ -55,6 +54,7 @@ import org.hibernate.metamodel.model.domain.IdentifiableDomainType;
|
||||||
import org.hibernate.metamodel.model.domain.JpaMetamodel;
|
import org.hibernate.metamodel.model.domain.JpaMetamodel;
|
||||||
import org.hibernate.metamodel.model.domain.ManagedDomainType;
|
import org.hibernate.metamodel.model.domain.ManagedDomainType;
|
||||||
import org.hibernate.metamodel.model.domain.MappedSuperclassDomainType;
|
import org.hibernate.metamodel.model.domain.MappedSuperclassDomainType;
|
||||||
|
import org.hibernate.metamodel.model.domain.PersistentAttribute;
|
||||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||||
import org.hibernate.persister.entity.Queryable;
|
import org.hibernate.persister.entity.Queryable;
|
||||||
import org.hibernate.query.sqm.tree.domain.SqmPolymorphicRootDescriptor;
|
import org.hibernate.query.sqm.tree.domain.SqmPolymorphicRootDescriptor;
|
||||||
|
@ -83,15 +83,16 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
private final JpaCompliance jpaCompliance;
|
private final JpaCompliance jpaCompliance;
|
||||||
|
|
||||||
private final Map<String, EntityDomainType<?>> jpaEntityTypeMap = new TreeMap<>(); // Need ordering for deterministic implementers list in SqmPolymorphicRootDescriptor
|
private final Map<String, EntityDomainType<?>> jpaEntityTypeMap = new TreeMap<>(); // Need ordering for deterministic implementers list in SqmPolymorphicRootDescriptor
|
||||||
private final Map<Class<?>, MappedSuperclassDomainType<?>> jpaMappedSuperclassTypeMap = new HashMap<>();
|
private final Map<Class<?>, ManagedDomainType<?>> jpaManagedTypeMap = new HashMap<>();
|
||||||
private final Map<Class, EmbeddableDomainType<?>> jpaEmbeddableDescriptorMap = new HashMap<>();
|
private final Set<ManagedDomainType<?>> jpaManagedTypes = new HashSet<>();
|
||||||
|
private final Set<EmbeddableDomainType<?>> jpaEmbeddables = new HashSet<>();
|
||||||
private final Map<String, Map<Class<?>, Enum<?>>> allowedEnumLiteralTexts = new HashMap<>();
|
private final Map<String, Map<Class<?>, Enum<?>>> allowedEnumLiteralTexts = new HashMap<>();
|
||||||
|
|
||||||
private final transient Map<String, RootGraphImplementor> entityGraphMap = new ConcurrentHashMap<>();
|
private final transient Map<String, RootGraphImplementor<?>> entityGraphMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private final Map<Class, SqmPolymorphicRootDescriptor<?>> polymorphicEntityReferenceMap = new ConcurrentHashMap<>();
|
private final Map<Class<?>, SqmPolymorphicRootDescriptor<?>> polymorphicEntityReferenceMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private final Map<Class, String> entityProxyInterfaceMap = new HashMap<>();
|
private final Map<Class<?>, String> entityProxyInterfaceMap = new HashMap<>();
|
||||||
|
|
||||||
private final Map<String, ImportInfo<?>> nameToImportMap = new ConcurrentHashMap<>();
|
private final Map<String, ImportInfo<?>> nameToImportMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@ -114,7 +115,7 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
@Override
|
@Override
|
||||||
public <X> EntityDomainType<X> entity(String entityName) {
|
public <X> EntityDomainType<X> entity(String entityName) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return (EntityDomainType) jpaEntityTypeMap.get( entityName );
|
return (EntityDomainType<X>) jpaEntityTypeMap.get( entityName );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -153,71 +154,25 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
return hqlEntityReference;
|
return hqlEntityReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void visitManagedTypes(Consumer<ManagedDomainType<?>> action) {
|
|
||||||
visitEntityTypes( (Consumer) action );
|
|
||||||
visitEmbeddables( (Consumer) action );
|
|
||||||
jpaMappedSuperclassTypeMap.values().forEach( action );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <X> ManagedDomainType<X> findManagedType(Class<X> cls) {
|
public <X> ManagedDomainType<X> findManagedType(Class<X> cls) {
|
||||||
ManagedType<?> type = jpaEntityTypeMap.get( cls.getName() );
|
|
||||||
if ( type == null ) {
|
|
||||||
type = jpaMappedSuperclassTypeMap.get( cls );
|
|
||||||
}
|
|
||||||
if ( type == null ) {
|
|
||||||
type = jpaEmbeddableDescriptorMap.get( cls );
|
|
||||||
}
|
|
||||||
if ( type == null ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return (ManagedDomainType<X>) type;
|
return (ManagedDomainType<X>) jpaManagedTypeMap.get( cls );
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void visitEntityTypes(Consumer<EntityDomainType<?>> action) {
|
|
||||||
jpaEntityTypeMap.values().forEach( action );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <X> EntityDomainType<X> findEntityType(Class<X> cls) {
|
public <X> EntityDomainType<X> findEntityType(Class<X> cls) {
|
||||||
final EntityType<?> entityType = jpaEntityTypeMap.get( cls.getName() );
|
final ManagedType<?> type = jpaManagedTypeMap.get( cls );
|
||||||
if ( entityType == null ) {
|
if ( !( type instanceof EntityType<?> ) ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return (EntityDomainType<X>) entityType;
|
return (EntityDomainType<X>) type;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void visitRootEntityTypes(Consumer<EntityDomainType<?>> action) {
|
|
||||||
jpaEntityTypeMap.values().forEach(
|
|
||||||
entityDomainType -> {
|
|
||||||
if ( entityDomainType.getSuperType() == null ) {
|
|
||||||
action.accept( entityDomainType );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void visitEmbeddables(Consumer<EmbeddableDomainType<?>> action) {
|
|
||||||
jpaEmbeddableDescriptorMap.values().forEach( action );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <X> ManagedDomainType<X> managedType(Class<X> cls) {
|
public <X> ManagedDomainType<X> managedType(Class<X> cls) {
|
||||||
ManagedType<?> type = jpaEntityTypeMap.get( cls.getName() );
|
final ManagedType<?> type = jpaManagedTypeMap.get( cls );
|
||||||
if ( type == null ) {
|
|
||||||
type = jpaMappedSuperclassTypeMap.get( cls );
|
|
||||||
}
|
|
||||||
if ( type == null ) {
|
|
||||||
type = jpaEmbeddableDescriptorMap.get( cls );
|
|
||||||
}
|
|
||||||
if ( type == null ) {
|
if ( type == null ) {
|
||||||
// per JPA
|
// per JPA
|
||||||
throw new IllegalArgumentException( "Not a managed type: " + cls );
|
throw new IllegalArgumentException( "Not a managed type: " + cls );
|
||||||
|
@ -229,44 +184,43 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <X> EntityDomainType<X> entity(Class<X> cls) {
|
public <X> EntityDomainType<X> entity(Class<X> cls) {
|
||||||
final EntityType<?> entityType = jpaEntityTypeMap.get( cls.getName() );
|
final ManagedType<?> type = jpaManagedTypeMap.get( cls );
|
||||||
if ( entityType == null ) {
|
if ( !( type instanceof EntityDomainType<?> ) ) {
|
||||||
throw new IllegalArgumentException( "Not an entity: " + cls.getName() );
|
throw new IllegalArgumentException( "Not an entity: " + cls.getName() );
|
||||||
}
|
}
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return (EntityDomainType<X>) entityType;
|
return (EntityDomainType<X>) type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <X> EmbeddableDomainType<X> embeddable(Class<X> cls) {
|
public <X> EmbeddableDomainType<X> embeddable(Class<X> cls) {
|
||||||
final EmbeddableDomainType<?> embeddableType = jpaEmbeddableDescriptorMap.get( cls );
|
final ManagedType<?> type = jpaManagedTypeMap.get( cls );
|
||||||
if ( embeddableType == null ) {
|
if ( !( type instanceof EntityDomainType<?> ) ) {
|
||||||
throw new IllegalArgumentException( "Not an embeddable: " + cls );
|
throw new IllegalArgumentException( "Not an embeddable: " + cls.getName() );
|
||||||
}
|
}
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return (EmbeddableDomainType<X>) embeddableType;
|
return (EmbeddableDomainType<X>) type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<ManagedType<?>> getManagedTypes() {
|
public Set<ManagedType<?>> getManagedTypes() {
|
||||||
final int setSize = CollectionHelper.determineProperSizing(
|
return new HashSet<>( jpaManagedTypes );
|
||||||
jpaEntityTypeMap.size() + jpaMappedSuperclassTypeMap.size() + jpaEmbeddableDescriptorMap.size()
|
|
||||||
);
|
|
||||||
final Set<ManagedType<?>> managedTypes = CollectionHelper.setOfSize( setSize );
|
|
||||||
managedTypes.addAll( jpaEntityTypeMap.values() );
|
|
||||||
managedTypes.addAll( jpaMappedSuperclassTypeMap.values() );
|
|
||||||
managedTypes.addAll( jpaEmbeddableDescriptorMap.values() );
|
|
||||||
return managedTypes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<EntityType<?>> getEntities() {
|
public Set<EntityType<?>> getEntities() {
|
||||||
return new HashSet<>( jpaEntityTypeMap.values() );
|
final Set<EntityType<?>> entityTypes = new HashSet<>( jpaEntityTypeMap.size() );
|
||||||
|
for ( ManagedDomainType<?> value : jpaManagedTypes ) {
|
||||||
|
if ( value instanceof EntityType<?> ) {
|
||||||
|
entityTypes.add( (EntityType<?>) value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return entityTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<EmbeddableType<?>> getEmbeddables() {
|
public Set<EmbeddableType<?>> getEmbeddables() {
|
||||||
return new HashSet<>( jpaEmbeddableDescriptorMap.values() );
|
return new HashSet<>( jpaEmbeddables );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -276,7 +230,7 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> void addNamedEntityGraph(String graphName, RootGraphImplementor<T> entityGraph) {
|
public <T> void addNamedEntityGraph(String graphName, RootGraphImplementor<T> entityGraph) {
|
||||||
final EntityGraph old = entityGraphMap.put(
|
final EntityGraph<?> old = entityGraphMap.put(
|
||||||
graphName,
|
graphName,
|
||||||
entityGraph.makeImmutableCopy( graphName )
|
entityGraph.makeImmutableCopy( graphName )
|
||||||
);
|
);
|
||||||
|
@ -289,7 +243,7 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
@Override
|
@Override
|
||||||
public <T> RootGraphImplementor<T> findEntityGraphByName(String name) {
|
public <T> RootGraphImplementor<T> findEntityGraphByName(String name) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return entityGraphMap.get( name );
|
return (RootGraphImplementor<T>) entityGraphMap.get( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -301,15 +255,14 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
|
|
||||||
final List<RootGraphImplementor<? super T>> results = new ArrayList<>();
|
final List<RootGraphImplementor<? super T>> results = new ArrayList<>();
|
||||||
|
|
||||||
for ( EntityGraph entityGraph : entityGraphMap.values() ) {
|
for ( EntityGraph<?> entityGraph : entityGraphMap.values() ) {
|
||||||
if ( !( entityGraph instanceof RootGraphImplementor ) ) {
|
if ( !( entityGraph instanceof RootGraphImplementor ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final RootGraphImplementor egi = (RootGraphImplementor) entityGraph;
|
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
|
final RootGraphImplementor<T> egi = (RootGraphImplementor<T>) entityGraph;
|
||||||
if ( egi.appliesTo( entityType ) ) {
|
if ( egi.appliesTo( entityType ) ) {
|
||||||
//noinspection unchecked
|
|
||||||
results.add( egi );
|
results.add( egi );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -326,6 +279,7 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
private <T> ImportInfo<T> resolveImport(final String name) {
|
private <T> ImportInfo<T> resolveImport(final String name) {
|
||||||
final ImportInfo<?> importInfo = nameToImportMap.get( name );
|
final ImportInfo<?> importInfo = nameToImportMap.get( name );
|
||||||
if ( importInfo != null ) {
|
if ( importInfo != null ) {
|
||||||
|
//noinspection unchecked
|
||||||
return importInfo == INVALID_IMPORT ? null : (ImportInfo<T>) importInfo;
|
return importInfo == INVALID_IMPORT ? null : (ImportInfo<T>) importInfo;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -360,7 +314,7 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
definition.getEntityName(),
|
definition.getEntityName(),
|
||||||
definition.getJpaEntityName()
|
definition.getJpaEntityName()
|
||||||
);
|
);
|
||||||
final EntityDomainType entityType = entity( definition.getEntityName() );
|
final EntityDomainType<Object> entityType = entity( definition.getEntityName() );
|
||||||
if ( entityType == null ) {
|
if ( entityType == null ) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Attempted to register named entity graph [" + definition.getRegisteredName()
|
"Attempted to register named entity graph [" + definition.getRegisteredName()
|
||||||
|
@ -369,7 +323,7 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final RootGraphImpl entityGraph = new RootGraphImpl(
|
final RootGraphImpl<Object> entityGraph = new RootGraphImpl<>(
|
||||||
definition.getRegisteredName(),
|
definition.getRegisteredName(),
|
||||||
entityType,
|
entityType,
|
||||||
this
|
this
|
||||||
|
@ -378,8 +332,8 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
final NamedEntityGraph namedEntityGraph = definition.getAnnotation();
|
final NamedEntityGraph namedEntityGraph = definition.getAnnotation();
|
||||||
|
|
||||||
if ( namedEntityGraph.includeAllAttributes() ) {
|
if ( namedEntityGraph.includeAllAttributes() ) {
|
||||||
for ( Object attributeObject : entityType.getAttributes() ) {
|
for ( Attribute<? super Object, ?> attribute : entityType.getAttributes() ) {
|
||||||
entityGraph.addAttributeNodes( (Attribute) attributeObject );
|
entityGraph.addAttributeNodes( attribute );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,12 +348,12 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
private void applyNamedAttributeNodes(
|
private void applyNamedAttributeNodes(
|
||||||
NamedAttributeNode[] namedAttributeNodes,
|
NamedAttributeNode[] namedAttributeNodes,
|
||||||
NamedEntityGraph namedEntityGraph,
|
NamedEntityGraph namedEntityGraph,
|
||||||
GraphImplementor graphNode) {
|
GraphImplementor<?> graphNode) {
|
||||||
for ( NamedAttributeNode namedAttributeNode : namedAttributeNodes ) {
|
for ( NamedAttributeNode namedAttributeNode : namedAttributeNodes ) {
|
||||||
final String value = namedAttributeNode.value();
|
final String value = namedAttributeNode.value();
|
||||||
AttributeNodeImplementor attributeNode = graphNode.addAttributeNode( value );
|
AttributeNodeImplementor<?> attributeNode = graphNode.addAttributeNode( value );
|
||||||
if ( StringHelper.isNotEmpty( namedAttributeNode.subgraph() ) ) {
|
if ( StringHelper.isNotEmpty( namedAttributeNode.subgraph() ) ) {
|
||||||
final SubGraphImplementor subgraph = attributeNode.makeSubGraph();
|
final SubGraphImplementor<?> subgraph = attributeNode.makeSubGraph();
|
||||||
applyNamedSubgraphs(
|
applyNamedSubgraphs(
|
||||||
namedEntityGraph,
|
namedEntityGraph,
|
||||||
namedAttributeNode.subgraph(),
|
namedAttributeNode.subgraph(),
|
||||||
|
@ -407,7 +361,7 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ( StringHelper.isNotEmpty( namedAttributeNode.keySubgraph() ) ) {
|
if ( StringHelper.isNotEmpty( namedAttributeNode.keySubgraph() ) ) {
|
||||||
final SubGraphImplementor subgraph = attributeNode.makeKeySubGraph();
|
final SubGraphImplementor<?> subgraph = attributeNode.makeKeySubGraph();
|
||||||
|
|
||||||
applyNamedSubgraphs(
|
applyNamedSubgraphs(
|
||||||
namedEntityGraph,
|
namedEntityGraph,
|
||||||
|
@ -421,7 +375,7 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
private void applyNamedSubgraphs(
|
private void applyNamedSubgraphs(
|
||||||
NamedEntityGraph namedEntityGraph,
|
NamedEntityGraph namedEntityGraph,
|
||||||
String subgraphName,
|
String subgraphName,
|
||||||
SubGraphImplementor subgraph) {
|
SubGraphImplementor<?> subgraph) {
|
||||||
for ( NamedSubgraph namedSubgraph : namedEntityGraph.subgraphs() ) {
|
for ( NamedSubgraph namedSubgraph : namedEntityGraph.subgraphs() ) {
|
||||||
if ( subgraphName.equals( namedSubgraph.name() ) ) {
|
if ( subgraphName.equals( namedSubgraph.name() ) ) {
|
||||||
applyNamedAttributeNodes(
|
applyNamedAttributeNodes(
|
||||||
|
@ -468,8 +422,7 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
final Set<EntityDomainType<?>> matchingDescriptors = new HashSet<>();
|
final Set<EntityDomainType<?>> matchingDescriptors = new HashSet<>();
|
||||||
visitEntityTypes(
|
for ( EntityDomainType<?> entityDomainType : jpaEntityTypeMap.values() ) {
|
||||||
entityDomainType -> {
|
|
||||||
if ( javaType.isAssignableFrom( entityDomainType.getJavaType() ) ) {
|
if ( javaType.isAssignableFrom( entityDomainType.getJavaType() ) ) {
|
||||||
final ManagedDomainType<?> superType = entityDomainType.getSuperType();
|
final ManagedDomainType<?> superType = entityDomainType.getSuperType();
|
||||||
// If the entity super type is also assignable, skip adding this entity type
|
// If the entity super type is also assignable, skip adding this entity type
|
||||||
|
@ -480,7 +433,7 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
.getEntityDescriptor( ( (EntityDomainType<?>) superType ).getHibernateEntityName() );
|
.getEntityDescriptor( ( (EntityDomainType<?>) superType ).getHibernateEntityName() );
|
||||||
// But only skip adding this type if the parent doesn't require explicit polymorphism
|
// But only skip adding this type if the parent doesn't require explicit polymorphism
|
||||||
if ( !entityPersister.isExplicitPolymorphism() ) {
|
if ( !entityPersister.isExplicitPolymorphism() ) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Queryable entityPersister = (Queryable) typeConfiguration.getSessionFactory()
|
final Queryable entityPersister = (Queryable) typeConfiguration.getSessionFactory()
|
||||||
|
@ -491,7 +444,6 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
|
||||||
if ( !matchingDescriptors.isEmpty() ) {
|
if ( !matchingDescriptors.isEmpty() ) {
|
||||||
final SqmPolymorphicRootDescriptor<T> descriptor = new SqmPolymorphicRootDescriptor<>(
|
final SqmPolymorphicRootDescriptor<T> descriptor = new SqmPolymorphicRootDescriptor<>(
|
||||||
typeConfiguration.getJavaTypeDescriptorRegistry().resolveDescriptor( javaType ),
|
typeConfiguration.getJavaTypeDescriptorRegistry().resolveDescriptor( javaType ),
|
||||||
|
@ -508,8 +460,9 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
public void processJpa(
|
public void processJpa(
|
||||||
MetadataImplementor bootMetamodel,
|
MetadataImplementor bootMetamodel,
|
||||||
MappingMetamodel mappingMetamodel,
|
MappingMetamodel mappingMetamodel,
|
||||||
Map<Class, String> entityProxyInterfaceMap,
|
Map<Class<?>, String> entityProxyInterfaceMap,
|
||||||
JpaStaticMetaModelPopulationSetting jpaStaticMetaModelPopulationSetting,
|
JpaStaticMetaModelPopulationSetting jpaStaticMetaModelPopulationSetting,
|
||||||
|
JpaMetaModelPopulationSetting jpaMetaModelPopulationSetting,
|
||||||
Collection<NamedEntityGraphDefinition> namedEntityGraphDefinitions,
|
Collection<NamedEntityGraphDefinition> namedEntityGraphDefinitions,
|
||||||
RuntimeModelCreationContext runtimeModelCreationContext) {
|
RuntimeModelCreationContext runtimeModelCreationContext) {
|
||||||
bootMetamodel.getImports().forEach( ( k, v ) -> this.nameToImportMap.put( k, new ImportInfo<>( v, null ) ) );
|
bootMetamodel.getImports().forEach( ( k, v ) -> this.nameToImportMap.put( k, new ImportInfo<>( v, null ) ) );
|
||||||
|
@ -532,19 +485,50 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
context.wrapUp();
|
context.wrapUp();
|
||||||
|
|
||||||
this.jpaEntityTypeMap.putAll( context.getEntityTypesByEntityName() );
|
this.jpaEntityTypeMap.putAll( context.getEntityTypesByEntityName() );
|
||||||
this.jpaMappedSuperclassTypeMap.putAll( context.getMappedSuperclassTypeMap() );
|
this.jpaManagedTypeMap.putAll( context.getEntityTypeMap() );
|
||||||
|
this.jpaManagedTypeMap.putAll( context.getMappedSuperclassTypeMap() );
|
||||||
for ( EmbeddableDomainType<?> embeddable : context.getEmbeddableTypeSet() ) {
|
this.jpaManagedTypes.addAll( context.getMappedSuperclassTypeMap().values() );
|
||||||
this.jpaEmbeddableDescriptorMap.put( embeddable.getJavaType(), embeddable );
|
switch ( jpaMetaModelPopulationSetting ) {
|
||||||
|
case IGNORE_UNSUPPORTED:
|
||||||
|
this.jpaManagedTypes.addAll( context.getEntityTypeMap().values() );
|
||||||
|
break;
|
||||||
|
case ENABLED:
|
||||||
|
this.jpaManagedTypes.addAll( context.getEntityTypesByEntityName().values() );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
domainTypeStream( context ).forEach( (managedDomainType) -> managedDomainType.visitAttributes( persistentAttribute -> {
|
for ( EmbeddableDomainType<?> embeddable : context.getEmbeddableTypeSet() ) {
|
||||||
|
switch ( jpaMetaModelPopulationSetting ) {
|
||||||
|
case IGNORE_UNSUPPORTED:
|
||||||
|
if ( embeddable.getJavaType() != null && embeddable.getJavaType() != Map.class ) {
|
||||||
|
this.jpaEmbeddables.add( embeddable );
|
||||||
|
this.jpaManagedTypes.add( embeddable );
|
||||||
|
this.jpaManagedTypeMap.put( embeddable.getJavaType(), embeddable );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ENABLED:
|
||||||
|
this.jpaEmbeddables.add( embeddable );
|
||||||
|
this.jpaManagedTypes.add( embeddable );
|
||||||
|
if ( embeddable.getJavaType() != null ) {
|
||||||
|
this.jpaManagedTypeMap.put( embeddable.getJavaType(), embeddable );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DISABLED:
|
||||||
|
if ( embeddable.getJavaType() == null ) {
|
||||||
|
throw new UnsupportedOperationException( "ANY not supported" );
|
||||||
|
}
|
||||||
|
this.jpaManagedTypeMap.put( embeddable.getJavaType(), embeddable );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final Consumer<PersistentAttribute<?, ?>> attributeConsumer = persistentAttribute -> {
|
||||||
if ( persistentAttribute.getJavaType() != null && persistentAttribute.getJavaType().isEnum() ) {
|
if ( persistentAttribute.getJavaType() != null && persistentAttribute.getJavaType().isEnum() ) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<Enum<?>> enumClass = (Class<Enum<?>>) persistentAttribute.getJavaType();
|
final Class<Enum<?>> enumClass = (Class<Enum<?>>) persistentAttribute.getJavaType();
|
||||||
Enum<?>[] enumConstants = enumClass.getEnumConstants();
|
final Enum<?>[] enumConstants = enumClass.getEnumConstants();
|
||||||
for ( Enum<?> enumConstant : enumConstants ) {
|
for ( Enum<?> enumConstant : enumConstants ) {
|
||||||
String qualifiedEnumLiteral = enumConstant.getDeclaringClass()
|
final String qualifiedEnumLiteral = enumConstant.getDeclaringClass()
|
||||||
.getSimpleName() + "." + enumConstant.name();
|
.getSimpleName() + "." + enumConstant.name();
|
||||||
|
|
||||||
this.allowedEnumLiteralTexts.computeIfAbsent(
|
this.allowedEnumLiteralTexts.computeIfAbsent(
|
||||||
|
@ -557,7 +541,10 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
|
||||||
).put( enumClass, enumConstant );
|
).put( enumClass, enumConstant );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} ) );
|
};
|
||||||
|
domainTypeStream( context ).forEach(
|
||||||
|
managedDomainType -> managedDomainType.visitAttributes( attributeConsumer )
|
||||||
|
);
|
||||||
|
|
||||||
applyNamedEntityGraphs( namedEntityGraphDefinitions );
|
applyNamedEntityGraphs( namedEntityGraphDefinitions );
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ import org.hibernate.mapping.Component;
|
||||||
import org.hibernate.mapping.MappedSuperclass;
|
import org.hibernate.mapping.MappedSuperclass;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.metamodel.MappingMetamodel;
|
import org.hibernate.metamodel.MappingMetamodel;
|
||||||
|
import org.hibernate.metamodel.internal.JpaMetaModelPopulationSetting;
|
||||||
import org.hibernate.metamodel.internal.JpaStaticMetaModelPopulationSetting;
|
import org.hibernate.metamodel.internal.JpaStaticMetaModelPopulationSetting;
|
||||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||||
import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess;
|
import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess;
|
||||||
|
@ -75,7 +76,8 @@ import org.hibernate.type.descriptor.java.JavaType;
|
||||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
import static org.hibernate.metamodel.internal.JpaStaticMetaModelPopulationSetting.determineJpaMetaModelPopulationSetting;
|
import static org.hibernate.metamodel.internal.JpaMetaModelPopulationSetting.determineJpaMetaModelPopulationSetting;
|
||||||
|
import static org.hibernate.metamodel.internal.JpaStaticMetaModelPopulationSetting.determineJpaStaticMetaModelPopulationSetting;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hibernate implementation of the JPA {@link jakarta.persistence.metamodel.Metamodel} contract.
|
* Hibernate implementation of the JPA {@link jakarta.persistence.metamodel.Metamodel} contract.
|
||||||
|
@ -103,7 +105,7 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
|
||||||
|
|
||||||
private final JpaMetamodel jpaMetamodel;
|
private final JpaMetamodel jpaMetamodel;
|
||||||
|
|
||||||
private final Map<Class, String> entityProxyInterfaceMap = new ConcurrentHashMap<>();
|
private final Map<Class<?>, String> entityProxyInterfaceMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -195,7 +197,8 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
|
||||||
|
|
||||||
final PersisterFactory persisterFactory = sessionFactory.getServiceRegistry().getService( PersisterFactory.class );
|
final PersisterFactory persisterFactory = sessionFactory.getServiceRegistry().getService( PersisterFactory.class );
|
||||||
|
|
||||||
final JpaStaticMetaModelPopulationSetting jpaStaticMetaModelPopulationSetting = determineJpaMetaModelPopulationSetting( sessionFactory.getProperties() );
|
final JpaStaticMetaModelPopulationSetting jpaStaticMetaModelPopulationSetting = determineJpaStaticMetaModelPopulationSetting( sessionFactory.getProperties() );
|
||||||
|
final JpaMetaModelPopulationSetting jpaMetaModelPopulationSetting = determineJpaMetaModelPopulationSetting( sessionFactory.getProperties() );
|
||||||
|
|
||||||
bootModel.visitRegisteredComponents( Component::prepareForMappingModel );
|
bootModel.visitRegisteredComponents( Component::prepareForMappingModel );
|
||||||
bootModel.getMappedSuperclassMappingsCopy().forEach( MappedSuperclass::prepareForMappingModel );
|
bootModel.getMappedSuperclassMappingsCopy().forEach( MappedSuperclass::prepareForMappingModel );
|
||||||
|
@ -238,6 +241,7 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
|
||||||
this,
|
this,
|
||||||
entityProxyInterfaceMap,
|
entityProxyInterfaceMap,
|
||||||
jpaStaticMetaModelPopulationSetting,
|
jpaStaticMetaModelPopulationSetting,
|
||||||
|
jpaMetaModelPopulationSetting,
|
||||||
bootModel.getNamedEntityGraphs().values(),
|
bootModel.getNamedEntityGraphs().values(),
|
||||||
runtimeModelCreationContext
|
runtimeModelCreationContext
|
||||||
);
|
);
|
||||||
|
@ -485,36 +489,16 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
|
||||||
return jpaMetamodel.resolveHqlEntityReference( entityName );
|
return jpaMetamodel.resolveHqlEntityReference( entityName );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void visitManagedTypes(Consumer<ManagedDomainType<?>> action) {
|
|
||||||
jpaMetamodel.visitManagedTypes( action );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <X> ManagedDomainType<X> findManagedType(Class<X> cls) {
|
public <X> ManagedDomainType<X> findManagedType(Class<X> cls) {
|
||||||
return jpaMetamodel.findManagedType( cls );
|
return jpaMetamodel.findManagedType( cls );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void visitEntityTypes(Consumer<EntityDomainType<?>> action) {
|
|
||||||
jpaMetamodel.visitEntityTypes( action );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <X> EntityDomainType<X> findEntityType(Class<X> cls) {
|
public <X> EntityDomainType<X> findEntityType(Class<X> cls) {
|
||||||
return jpaMetamodel.findEntityType( cls );
|
return jpaMetamodel.findEntityType( cls );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void visitRootEntityTypes(Consumer<EntityDomainType<?>> action) {
|
|
||||||
jpaMetamodel.visitRootEntityTypes( action );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void visitEmbeddables(Consumer<EmbeddableDomainType<?>> action) {
|
|
||||||
jpaMetamodel.visitEmbeddables( action );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String qualifyImportableName(String queryName) {
|
public String qualifyImportableName(String queryName) {
|
||||||
return jpaMetamodel.qualifyImportableName( queryName );
|
return jpaMetamodel.qualifyImportableName( queryName );
|
||||||
|
|
|
@ -169,12 +169,12 @@ public class SqmPolymorphicRootDescriptor<T> implements EntityDomainType<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitAttributes(Consumer<PersistentAttribute<T, ?>> action) {
|
public void visitAttributes(Consumer<? super PersistentAttribute<T, ?>> action) {
|
||||||
commonAttributes.values().forEach( (Consumer) action );
|
commonAttributes.values().forEach( (Consumer) action );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitDeclaredAttributes(Consumer<PersistentAttribute<T, ?>> action) {
|
public void visitDeclaredAttributes(Consumer<? super PersistentAttribute<T, ?>> action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class IdClassHbmTest extends BaseCoreFunctionalTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected void configure(Configuration configuration) {
|
protected void configure(Configuration configuration) {
|
||||||
// the Customer entity has a composite id that is not embeddable ( not supported by JPA ).
|
// the Customer entity has a composite id that is not embeddable ( not supported by JPA ).
|
||||||
configuration.setProperty( AvailableSettings.STATIC_METAMODEL_POPULATION, "disabled" );
|
configuration.setProperty( AvailableSettings.JPA_METAMODEL_POPULATION, "disabled" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
|
||||||
* @author Brad Koehn
|
* @author Brad Koehn
|
||||||
*/
|
*/
|
||||||
@Jpa(
|
@Jpa(
|
||||||
integrationSettings = { @Setting(name = AvailableSettings.STATIC_METAMODEL_POPULATION, value = "enabled") },
|
integrationSettings = { @Setting(name = AvailableSettings.JPA_METAMODEL_POPULATION, value = "enabled") },
|
||||||
xmlMappings = { "org/hibernate/orm/test/jpa/criteria/paths/PolicyAndDistribution.hbm.xml" }
|
xmlMappings = { "org/hibernate/orm/test/jpa/criteria/paths/PolicyAndDistribution.hbm.xml" }
|
||||||
)
|
)
|
||||||
public class SingularAttributeJoinTest {
|
public class SingularAttributeJoinTest {
|
||||||
|
|
|
@ -76,7 +76,7 @@ public abstract class AbstractJpaMetamodelPopulationTest extends BaseEntityManag
|
||||||
@Override
|
@Override
|
||||||
protected void addConfigOptions(Map options) {
|
protected void addConfigOptions(Map options) {
|
||||||
super.addConfigOptions( options );
|
super.addConfigOptions( options );
|
||||||
options.put( AvailableSettings.STATIC_METAMODEL_POPULATION, getJpaMetamodelPopulationValue() );
|
options.put( AvailableSettings.JPA_METAMODEL_POPULATION, getJpaMetamodelPopulationValue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -120,7 +120,7 @@ public abstract class AbstractJpaMetamodelPopulationTest extends BaseEntityManag
|
||||||
assertEquals( 8, metamodel.getManagedTypes().size() );
|
assertEquals( 8, metamodel.getManagedTypes().size() );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// When skipUnsupported is used, any managed-type that refers to a dynamic-map entity type
|
// When ignoreUnsupported is used, any managed-type that refers to a dynamic-map entity type
|
||||||
// or a managed type that is owned by said dynamic-map entity type should be excluded.
|
// or a managed type that is owned by said dynamic-map entity type should be excluded.
|
||||||
// Therefore this collection should only include 3 elements
|
// Therefore this collection should only include 3 elements
|
||||||
// EntityType(SimpleAnnotated)
|
// EntityType(SimpleAnnotated)
|
||||||
|
|
|
@ -4,9 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.jpa.test.metamodel;
|
package org.hibernate.orm.test.jpa.metamodel;
|
||||||
|
|
||||||
import org.hibernate.orm.test.jpa.metamodel.AbstractJpaMetamodelPopulationTest;
|
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
|
|
@ -4,9 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.jpa.test.metamodel;
|
package org.hibernate.orm.test.jpa.metamodel;
|
||||||
|
|
||||||
import org.hibernate.orm.test.jpa.metamodel.AbstractJpaMetamodelPopulationTest;
|
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
|
|
@ -4,9 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.jpa.test.metamodel;
|
package org.hibernate.orm.test.jpa.metamodel;
|
||||||
|
|
||||||
import org.hibernate.orm.test.jpa.metamodel.AbstractJpaMetamodelPopulationTest;
|
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
|
||||||
|
@ -14,9 +12,9 @@ import org.hibernate.testing.TestForIssue;
|
||||||
* @author Chris Cranford
|
* @author Chris Cranford
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-12871")
|
@TestForIssue(jiraKey = "HHH-12871")
|
||||||
public class JpaMetamodelskipUnsupportedPopulationTest extends AbstractJpaMetamodelPopulationTest {
|
public class JpaMetamodelIgnoreUnsupportedPopulationTest extends AbstractJpaMetamodelPopulationTest {
|
||||||
@Override
|
@Override
|
||||||
protected String getJpaMetamodelPopulationValue() {
|
protected String getJpaMetamodelPopulationValue() {
|
||||||
return "skipUnsupported";
|
return "ignoreUnsupported";
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -33,8 +33,8 @@ import static org.hamcrest.Matchers.nullValue;
|
||||||
)
|
)
|
||||||
@ServiceRegistry(
|
@ServiceRegistry(
|
||||||
settings = @Setting(
|
settings = @Setting(
|
||||||
name = AvailableSettings.STATIC_METAMODEL_POPULATION,
|
name = AvailableSettings.JPA_METAMODEL_POPULATION,
|
||||||
value = "skipUnsupported"
|
value = "ignoreUnsupported"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@DomainModel( annotatedClasses = BasicContributorTests.MainEntity.class )
|
@DomainModel( annotatedClasses = BasicContributorTests.MainEntity.class )
|
||||||
|
|
|
@ -10,13 +10,17 @@ import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
import org.hibernate.boot.spi.MetadataImplementor;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
|
import org.hibernate.envers.DefaultRevisionEntity;
|
||||||
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.metamodel.RuntimeMetamodels;
|
import org.hibernate.metamodel.RuntimeMetamodels;
|
||||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
|
|
||||||
import org.hibernate.testing.orm.junit.DomainModel;
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
import org.hibernate.testing.orm.junit.DomainModelScope;
|
||||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
|
@ -24,6 +28,7 @@ import org.hibernate.testing.orm.junit.Setting;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.Matchers.notNullValue;
|
import static org.hamcrest.Matchers.notNullValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,8 +36,8 @@ import static org.hamcrest.Matchers.notNullValue;
|
||||||
*/
|
*/
|
||||||
@ServiceRegistry(
|
@ServiceRegistry(
|
||||||
settings = @Setting(
|
settings = @Setting(
|
||||||
name = AvailableSettings.STATIC_METAMODEL_POPULATION,
|
name = AvailableSettings.JPA_METAMODEL_POPULATION,
|
||||||
value = "skipUnsupported"
|
value = "ignoreUnsupported"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@DomainModel(
|
@DomainModel(
|
||||||
|
|
Loading…
Reference in New Issue