Introduce `VirtualIdEmbeddable` and `IdClassEmbeddable`
Clean-up Still need to - integrate EmbeddableInstantiator work - integrate embedded forms. `VirtualIdEmbeddable` does not really need it as it can use the id-mapping itself as the embedded form. But `IdClassEmbedded` should really be integrated - integrate `VirtualKeyEmbeddable` and `VirtualKeyEmbedded` for use as inverse composite fks - share `#finishInit` handling for `EmbeddableMappingType`, `VirtualIdEmbeddable` and `IdClassEmbeddable`
This commit is contained in:
parent
0322d8fa84
commit
bb2b0a6c47
|
@ -11,7 +11,6 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
|
|
||||||
import org.hibernate.FetchMode;
|
import org.hibernate.FetchMode;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
|
@ -68,7 +67,6 @@ import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
||||||
import org.hibernate.metamodel.mapping.PropertyBasedMapping;
|
import org.hibernate.metamodel.mapping.PropertyBasedMapping;
|
||||||
import org.hibernate.metamodel.mapping.SelectableMapping;
|
import org.hibernate.metamodel.mapping.SelectableMapping;
|
||||||
import org.hibernate.metamodel.mapping.SelectableMappings;
|
import org.hibernate.metamodel.mapping.SelectableMappings;
|
||||||
import org.hibernate.metamodel.mapping.SingularAttributeMapping;
|
|
||||||
import org.hibernate.metamodel.mapping.StateArrayContributorMetadata;
|
import org.hibernate.metamodel.mapping.StateArrayContributorMetadata;
|
||||||
import org.hibernate.metamodel.mapping.StateArrayContributorMetadataAccess;
|
import org.hibernate.metamodel.mapping.StateArrayContributorMetadataAccess;
|
||||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||||
|
@ -149,9 +147,7 @@ public class MappingModelCreationHelper {
|
||||||
EntityPersister entityPersister,
|
EntityPersister entityPersister,
|
||||||
String rootTableName,
|
String rootTableName,
|
||||||
String[] rootTableKeyColumnNames,
|
String[] rootTableKeyColumnNames,
|
||||||
CompositeType cidType,
|
|
||||||
PersistentClass bootEntityDescriptor,
|
PersistentClass bootEntityDescriptor,
|
||||||
BiConsumer<String,SingularAttributeMapping> idSubAttributeConsumer,
|
|
||||||
MappingModelCreationProcess creationProcess) {
|
MappingModelCreationProcess creationProcess) {
|
||||||
return new NonAggregatedIdentifierMappingImpl(
|
return new NonAggregatedIdentifierMappingImpl(
|
||||||
entityPersister,
|
entityPersister,
|
||||||
|
@ -160,81 +156,6 @@ public class MappingModelCreationHelper {
|
||||||
rootTableKeyColumnNames,
|
rootTableKeyColumnNames,
|
||||||
creationProcess
|
creationProcess
|
||||||
);
|
);
|
||||||
|
|
||||||
// final Component bootIdClassComponent = (Component) bootEntityDescriptor.getIdentifier();
|
|
||||||
// final Component bootVirtualComponent;
|
|
||||||
// if ( bootEntityDescriptor.getIdentifierMapper() == null ) {
|
|
||||||
// // If there is no id-class, there apparently also is no id mapper
|
|
||||||
// bootVirtualComponent = bootIdClassComponent;
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// bootVirtualComponent = bootEntityDescriptor.getIdentifierMapper();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// final EmbeddableMappingType embeddableMappingType = EmbeddableMappingType.from(
|
|
||||||
// bootVirtualComponent,
|
|
||||||
// (CompositeType) bootVirtualComponent.getType(),
|
|
||||||
// rootTableName,
|
|
||||||
// rootTableKeyColumnNames,
|
|
||||||
// attributeMappingType -> {
|
|
||||||
// final PropertyAccess propertyAccess = PropertyAccessStrategyMapImpl.INSTANCE.buildPropertyAccess(
|
|
||||||
// null,
|
|
||||||
// EntityIdentifierMapping.ROLE_LOCAL_NAME
|
|
||||||
// );
|
|
||||||
// final StateArrayContributorMetadataAccess attributeMetadataAccess = getStateArrayContributorMetadataAccess(
|
|
||||||
// propertyAccess
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// final EmbeddableMappingType idClassType;
|
|
||||||
// if ( bootIdClassComponent != bootVirtualComponent ) {
|
|
||||||
// idClassType = EmbeddableMappingType.from(
|
|
||||||
// bootIdClassComponent,
|
|
||||||
// (CompositeType) bootIdClassComponent.getType(),
|
|
||||||
// rootTableName,
|
|
||||||
// rootTableKeyColumnNames,
|
|
||||||
// idClassEmbeddableType -> new EmbeddedAttributeMapping(
|
|
||||||
// "{id-class}",
|
|
||||||
// entityPersister.getNavigableRole()
|
|
||||||
// .append( EntityIdentifierMapping.ROLE_LOCAL_NAME )
|
|
||||||
// .append( "{id-class}" ),
|
|
||||||
// -1,
|
|
||||||
// null,
|
|
||||||
// attributeMetadataAccess,
|
|
||||||
// (String) null,
|
|
||||||
// FetchTiming.IMMEDIATE,
|
|
||||||
// FetchStyle.JOIN,
|
|
||||||
// idClassEmbeddableType,
|
|
||||||
// entityPersister,
|
|
||||||
// propertyAccess,
|
|
||||||
// null
|
|
||||||
// ),
|
|
||||||
// creationProcess
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// idClassType = attributeMappingType;
|
|
||||||
// }
|
|
||||||
// return new NonAggregatedIdentifierMappingImpl(
|
|
||||||
// attributeMappingType,
|
|
||||||
// entityPersister,
|
|
||||||
// idClassType,
|
|
||||||
// attributeMetadataAccess,
|
|
||||||
// rootTableName,
|
|
||||||
// creationProcess
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
// creationProcess
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// // Inject the model part also in the composite type of the id-class, because that is what we actually "instantiate"
|
|
||||||
// // which needs the model part for instantiation
|
|
||||||
//// final CompositeIdentifierMapping compositeIdentifierMapping = (CompositeIdentifierMapping) virtualIdEmbeddable.getEmbeddedValueMapping();
|
|
||||||
//// ( (CompositeTypeImplementor) virtualIdSource.getType() ).injectMappingModelPart(
|
|
||||||
//// (EmbeddableValuedModelPart) compositeIdentifierMapping,
|
|
||||||
//// creationProcess
|
|
||||||
//// );
|
|
||||||
//
|
|
||||||
// return compositeIdentifierMapping;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -319,6 +240,7 @@ public class MappingModelCreationHelper {
|
||||||
// we want to "decompose" the "type" into its various pieces as expected by the mapping
|
// we want to "decompose" the "type" into its various pieces as expected by the mapping
|
||||||
assert valueConverter.getRelationalJavaDescriptor() == resolution.getRelationalJavaDescriptor();
|
assert valueConverter.getRelationalJavaDescriptor() == resolution.getRelationalJavaDescriptor();
|
||||||
|
|
||||||
|
//noinspection unchecked
|
||||||
final BasicType<?> mappingBasicType = creationProcess.getCreationContext()
|
final BasicType<?> mappingBasicType = creationProcess.getCreationContext()
|
||||||
.getDomainModel()
|
.getDomainModel()
|
||||||
.getTypeConfiguration()
|
.getTypeConfiguration()
|
||||||
|
|
|
@ -5878,7 +5878,7 @@ public abstract class AbstractEntityPersister
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise we have a non-encapsulated composite-identifier
|
// otherwise we have a non-encapsulated composite-identifier
|
||||||
return generateNonEncapsulatedCompositeIdentifierMapping( creationProcess, bootEntityDescriptor, cidType );
|
return generateNonEncapsulatedCompositeIdentifierMapping( creationProcess, bootEntityDescriptor );
|
||||||
}
|
}
|
||||||
|
|
||||||
return new BasicEntityIdentifierMappingImpl(
|
return new BasicEntityIdentifierMappingImpl(
|
||||||
|
@ -5894,17 +5894,14 @@ public abstract class AbstractEntityPersister
|
||||||
|
|
||||||
protected EntityIdentifierMapping generateNonEncapsulatedCompositeIdentifierMapping(
|
protected EntityIdentifierMapping generateNonEncapsulatedCompositeIdentifierMapping(
|
||||||
MappingModelCreationProcess creationProcess,
|
MappingModelCreationProcess creationProcess,
|
||||||
PersistentClass bootEntityDescriptor,
|
PersistentClass bootEntityDescriptor) {
|
||||||
CompositeType cidType) {
|
|
||||||
assert declaredAttributeMappings != null;
|
assert declaredAttributeMappings != null;
|
||||||
|
|
||||||
return MappingModelCreationHelper.buildNonEncapsulatedCompositeIdentifierMapping(
|
return MappingModelCreationHelper.buildNonEncapsulatedCompositeIdentifierMapping(
|
||||||
this,
|
this,
|
||||||
getTableName(),
|
getTableName(),
|
||||||
getRootTableKeyColumnNames(),
|
getRootTableKeyColumnNames(),
|
||||||
cidType,
|
|
||||||
bootEntityDescriptor,
|
bootEntityDescriptor,
|
||||||
declaredAttributeMappings::put,
|
|
||||||
creationProcess
|
creationProcess
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ package org.hibernate.persister.entity;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -1215,7 +1214,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise we have a non-encapsulated composite-identifier
|
// otherwise we have a non-encapsulated composite-identifier
|
||||||
return generateNonEncapsulatedCompositeIdentifierMapping( creationProcess, bootEntityDescriptor, cidType );
|
return generateNonEncapsulatedCompositeIdentifierMapping( creationProcess, bootEntityDescriptor );
|
||||||
}
|
}
|
||||||
|
|
||||||
return new BasicEntityIdentifierMappingImpl(
|
return new BasicEntityIdentifierMappingImpl(
|
||||||
|
@ -1265,17 +1264,14 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
|
|
||||||
protected EntityIdentifierMapping generateNonEncapsulatedCompositeIdentifierMapping(
|
protected EntityIdentifierMapping generateNonEncapsulatedCompositeIdentifierMapping(
|
||||||
MappingModelCreationProcess creationProcess,
|
MappingModelCreationProcess creationProcess,
|
||||||
PersistentClass bootEntityDescriptor,
|
PersistentClass bootEntityDescriptor) {
|
||||||
CompositeType cidType) {
|
|
||||||
assert declaredAttributeMappings != null;
|
assert declaredAttributeMappings != null;
|
||||||
|
|
||||||
return MappingModelCreationHelper.buildNonEncapsulatedCompositeIdentifierMapping(
|
return MappingModelCreationHelper.buildNonEncapsulatedCompositeIdentifierMapping(
|
||||||
this,
|
this,
|
||||||
getTableName(),
|
getTableName(),
|
||||||
tableKeyColumns[0],
|
tableKeyColumns[0],
|
||||||
cidType,
|
|
||||||
bootEntityDescriptor,
|
bootEntityDescriptor,
|
||||||
declaredAttributeMappings::put,
|
|
||||||
creationProcess
|
creationProcess
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue