mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-16 16:15:06 +00:00
6 - SQM based on JPA type system
- SQM tests
This commit is contained in:
parent
1003ddf115
commit
62b98712d4
@ -247,7 +247,7 @@ public static <Y> SimpleDomainType<Y> determineSimpleType(ValueContext typeConte
|
||||
context.getJpaMetamodel()
|
||||
);
|
||||
|
||||
context.registerEmbeddableType( embeddableType );
|
||||
context.registerEmbeddableType( embeddableType, component );
|
||||
|
||||
return embeddableType;
|
||||
}
|
||||
|
@ -81,6 +81,8 @@ public class MetadataContext {
|
||||
private Map<PersistentClass, EntityDomainType<?>> entityTypesByPersistentClass = new HashMap<>();
|
||||
|
||||
private Map<Class, EmbeddableDomainType<?>> embeddables = new HashMap<>();
|
||||
private Map<Class, EmbeddableDomainType<?>> embeddablesToProcess = new HashMap<>();
|
||||
private Map<EmbeddableDomainType<?>,Component> componentByEmbeddable = new HashMap<>();
|
||||
|
||||
private Map<MappedSuperclass, MappedSuperclassDomainType<?>> mappedSuperclassByMappedSuperclassMapping = new HashMap<>();
|
||||
private Map<MappedSuperclassDomainType<?>, PersistentClass> mappedSuperClassTypeToPersistentClass = new HashMap<>();
|
||||
@ -166,11 +168,14 @@ public void registerEntityType(PersistentClass persistentClass, EntityTypeImpl<
|
||||
orderedMappings.add( persistentClass );
|
||||
}
|
||||
|
||||
public void registerEmbeddableType(EmbeddableDomainType<?> embeddableType) {
|
||||
public void registerEmbeddableType(
|
||||
EmbeddableDomainType<?> embeddableType,
|
||||
Component bootDescriptor) {
|
||||
assert embeddableType.getJavaType() != null;
|
||||
assert ! Map.class.isAssignableFrom( embeddableType.getJavaType() );
|
||||
|
||||
embeddables.put( embeddableType.getJavaType(), embeddableType );
|
||||
embeddablesToProcess.put( embeddableType.getJavaType(), embeddableType );
|
||||
componentByEmbeddable.put( embeddableType, bootDescriptor );
|
||||
}
|
||||
|
||||
public void registerMappedSuperclassType(
|
||||
@ -318,9 +323,27 @@ else if ( MappedSuperclass.class.isAssignableFrom( mapping.getClass() ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( staticMetamodelScanEnabled ) {
|
||||
for ( EmbeddableDomainType embeddable : embeddables.values() ) {
|
||||
populateStaticMetamodel( embeddable );
|
||||
|
||||
while ( ! embeddablesToProcess.isEmpty() ) {
|
||||
final ArrayList<EmbeddableDomainType<?>> processingEmbeddables = new ArrayList<>( embeddablesToProcess.values() );
|
||||
embeddablesToProcess.clear();
|
||||
|
||||
for ( EmbeddableDomainType<?> embeddable : processingEmbeddables ) {
|
||||
final Component component = componentByEmbeddable.get( embeddable );
|
||||
final Iterator<Property> propertyItr = component.getPropertyIterator();
|
||||
while ( propertyItr.hasNext() ) {
|
||||
final Property property = propertyItr.next();
|
||||
final PersistentAttribute attribute = attributeFactory.buildAttribute( embeddable, property );
|
||||
if ( attribute != null ) {
|
||||
( ( AttributeContainer) embeddable ).getInFlightAccess().addAttribute( attribute );
|
||||
}
|
||||
}
|
||||
|
||||
( ( AttributeContainer) embeddable ).getInFlightAccess().finishUp();
|
||||
|
||||
if ( staticMetamodelScanEnabled ) {
|
||||
populateStaticMetamodel( embeddable );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -591,6 +614,11 @@ public <J> BasicDomainType<J> resolveBasicType(Class<J> javaType) {
|
||||
|
||||
public <J> EmbeddableDomainType<J> locateEmbeddable(Class<J> embeddableClass) {
|
||||
//noinspection unchecked
|
||||
return (EmbeddableDomainType<J>) embeddables.get( embeddableClass );
|
||||
EmbeddableDomainType<J> domainType = (EmbeddableDomainType<J>) embeddables.get( embeddableClass );
|
||||
if ( domainType == null ) {
|
||||
//noinspection unchecked
|
||||
domainType = (EmbeddableDomainType) embeddablesToProcess.get( embeddableClass );
|
||||
}
|
||||
return domainType;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user