use of org.hibernate.metamodel.model.domain.TupleType in project hibernate-orm by hibernate.
the class MappingMetamodelImpl method resolveMappingExpressible.
@Override
public MappingModelExpressible<?> resolveMappingExpressible(SqmExpressible<?> sqmExpressible, Function<NavigablePath, TableGroup> tableGroupLocator) {
if (sqmExpressible instanceof SqmPath) {
final SqmPath<?> sqmPath = (SqmPath<?>) sqmExpressible;
final NavigablePath navigablePath = sqmPath.getNavigablePath();
if (navigablePath.getParent() != null) {
final TableGroup parentTableGroup = tableGroupLocator.apply(navigablePath.getParent());
return parentTableGroup.getModelPart().findSubPart(navigablePath.getLocalName(), null);
}
return tableGroupLocator.apply(navigablePath.getParent()).getModelPart();
}
if (sqmExpressible instanceof BasicType<?>) {
return (BasicType<?>) sqmExpressible;
}
if (sqmExpressible instanceof BasicSqmPathSource<?>) {
return getTypeConfiguration().getBasicTypeForJavaType(((BasicSqmPathSource<?>) sqmExpressible).getJavaType());
}
if (sqmExpressible instanceof SqmFieldLiteral) {
return getTypeConfiguration().getBasicTypeForJavaType(((SqmFieldLiteral<?>) sqmExpressible).getJavaType());
}
if (sqmExpressible instanceof CompositeSqmPathSource) {
throw new NotYetImplementedFor6Exception("Resolution of embedded-valued SqmExpressible nodes not yet implemented");
}
if (sqmExpressible instanceof EmbeddableTypeImpl) {
return (MappingModelExpressible<?>) sqmExpressible;
}
if (sqmExpressible instanceof EntityDomainType<?>) {
return getEntityDescriptor(((EntityDomainType<?>) sqmExpressible).getHibernateEntityName());
}
if (sqmExpressible instanceof TupleType<?>) {
final MappingModelExpressible<?> mappingModelExpressible = tupleTypeCache.get(sqmExpressible);
if (mappingModelExpressible != null) {
return mappingModelExpressible;
}
final TupleType<?> tupleType = (TupleType<?>) sqmExpressible;
final MappingModelExpressible<?>[] components = new MappingModelExpressible<?>[tupleType.componentCount()];
for (int i = 0; i < components.length; i++) {
components[i] = resolveMappingExpressible(tupleType.get(i), tableGroupLocator);
}
final MappingModelExpressible<?> createdMappingModelExpressible = new TupleMappingModelExpressible(components);
final MappingModelExpressible<?> existingMappingModelExpressible = tupleTypeCache.putIfAbsent(tupleType, createdMappingModelExpressible);
return existingMappingModelExpressible == null ? createdMappingModelExpressible : existingMappingModelExpressible;
}
return null;
}
Aggregations