use of org.hibernate.query.sqm.sql.internal.SqmMapEntryResult in project hibernate-orm by hibernate.
the class BaseSqmToSqlAstConverter method visitMapEntryFunction.
@Override
public Object visitMapEntryFunction(SqmMapEntryReference<?, ?> entryRef) {
final SqmPath<?> mapPath = entryRef.getMapPath();
prepareReusablePath(mapPath, () -> null);
final NavigablePath mapNavigablePath = mapPath.getNavigablePath();
final TableGroup tableGroup = getFromClauseAccess().resolveTableGroup(mapNavigablePath, (navigablePath) -> {
final TableGroup parentTableGroup = getFromClauseAccess().getTableGroup(mapNavigablePath.getParent());
final PluralAttributeMapping mapAttribute = (PluralAttributeMapping) parentTableGroup.getModelPart().findSubPart(mapNavigablePath.getLocalName(), null);
final TableGroupJoin tableGroupJoin = mapAttribute.createTableGroupJoin(mapNavigablePath, parentTableGroup, null, SqlAstJoinType.INNER, false, false, sqlAliasBaseManager, getSqlExpressionResolver(), this, creationContext);
parentTableGroup.addTableGroupJoin(tableGroupJoin);
return tableGroupJoin.getJoinedGroup();
});
final PluralAttributeMapping mapDescriptor = (PluralAttributeMapping) tableGroup.getModelPart();
final CollectionPart indexDescriptor = mapDescriptor.getIndexDescriptor();
final NavigablePath indexNavigablePath = mapNavigablePath.append(indexDescriptor.getPartName());
final DomainResult<Object> indexResult = indexDescriptor.createDomainResult(indexNavigablePath, tableGroup, null, this);
final CollectionPart valueDescriptor = mapDescriptor.getElementDescriptor();
final NavigablePath valueNavigablePath = mapNavigablePath.append(valueDescriptor.getPartName());
final DomainResult<Object> valueResult = valueDescriptor.createDomainResult(valueNavigablePath, tableGroup, null, this);
return new DomainResultProducer<Map.Entry<Object, Object>>() {
@Override
public DomainResult<Map.Entry<Object, Object>> createDomainResult(String resultVariable, DomainResultCreationState creationState) {
final JavaType<Map.Entry<Object, Object>> mapEntryDescriptor = getTypeConfiguration().getJavaTypeRegistry().resolveDescriptor(Map.Entry.class);
return new SqmMapEntryResult<>(indexResult, valueResult, resultVariable, mapEntryDescriptor);
}
@Override
public void applySqlSelections(DomainResultCreationState creationState) {
throw new UnsupportedOperationException();
}
};
}
Aggregations