use of org.hibernate.query.sqm.BinaryArithmeticOperator.ADD in project hibernate-orm by hibernate.
the class BaseSqmToSqlAstConverter method consumeSqmParameter.
protected Expression consumeSqmParameter(SqmParameter<?> sqmParameter, MappingModelExpressible<?> valueMapping, BiConsumer<Integer, JdbcParameter> jdbcParameterConsumer) {
final List<JdbcParameter> jdbcParametersForSqm = new ArrayList<>();
resolveSqmParameter(sqmParameter, valueMapping, (index, jdbcParameter) -> {
jdbcParameterConsumer.accept(index, jdbcParameter);
jdbcParametersForSqm.add(jdbcParameter);
});
this.jdbcParameters.addParameters(jdbcParametersForSqm);
this.jdbcParamsBySqmParam.computeIfAbsent(sqmParameter, k -> new ArrayList<>(1)).add(jdbcParametersForSqm);
final QueryParameterImplementor<?> queryParameter = domainParameterXref.getQueryParameter(sqmParameter);
final QueryParameterBinding binding = domainParameterBindings.getBinding(queryParameter);
if (binding.setType(valueMapping)) {
replaceJdbcParametersType(sqmParameter, domainParameterXref.getSqmParameters(queryParameter), valueMapping);
}
return new SqmParameterInterpretation(sqmParameter, queryParameter, jdbcParametersForSqm, valueMapping, qp -> binding);
}
use of org.hibernate.query.sqm.BinaryArithmeticOperator.ADD in project hibernate-orm by hibernate.
the class BaseSqmToSqlAstConverter method consumeSingleSqmParameter.
protected Expression consumeSingleSqmParameter(SqmParameter<?> sqmParameter) {
final MappingModelExpressible<?> valueMapping = determineValueMapping(sqmParameter);
final List<JdbcParameter> jdbcParametersForSqm = new ArrayList<>();
resolveSqmParameter(sqmParameter, valueMapping, jdbcParametersForSqm::add);
this.jdbcParameters.addParameters(jdbcParametersForSqm);
this.jdbcParamsBySqmParam.computeIfAbsent(sqmParameter, k -> new ArrayList<>(1)).add(jdbcParametersForSqm);
final QueryParameterImplementor<?> queryParameter = domainParameterXref.getQueryParameter(sqmParameter);
final QueryParameterBinding binding = domainParameterBindings.getBinding(queryParameter);
if (binding.setType(valueMapping)) {
replaceJdbcParametersType(sqmParameter, domainParameterXref.getSqmParameters(queryParameter), valueMapping);
}
return new SqmParameterInterpretation(sqmParameter, queryParameter, jdbcParametersForSqm, valueMapping, qp -> binding);
}
use of org.hibernate.query.sqm.BinaryArithmeticOperator.ADD in project hibernate-orm by hibernate.
the class BaseSqmToSqlAstConverter method withTreatRestriction.
private Expression withTreatRestriction(Expression expression, SqmPath<?> path) {
final SqmPath<?> lhs;
if (path instanceof SqmTreatedPath<?, ?>) {
lhs = path;
} else {
lhs = path.getLhs();
}
if (lhs instanceof SqmTreatedPath<?, ?>) {
final SqmTreatedPath<?, ?> treatedPath = (SqmTreatedPath<?, ?>) lhs;
final Class<?> treatTargetJavaType = treatedPath.getTreatTarget().getJavaType();
final Class<?> originalJavaType = treatedPath.getWrappedPath().getJavaType();
if (treatTargetJavaType.isAssignableFrom(originalJavaType)) {
// Treating a node to a super type can be ignored
return expression;
}
if (!(expression.getExpressionType() instanceof BasicValuedMapping)) {
// A case wrapper for non-basic paths is not possible,
// because a case expression must return a scalar value,
// so we instead add the type restriction predicate as conjunct
final MappingMetamodel domainModel = creationContext.getSessionFactory().getRuntimeMetamodels().getMappingMetamodel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(treatedPath.getTreatTarget().getHibernateEntityName());
conjunctTreatUsages.computeIfAbsent(treatedPath.getWrappedPath(), p -> new HashSet<>(1)).addAll(entityDescriptor.getSubclassEntityNames());
return expression;
}
// Note: If the columns that are accessed are not shared with other entities, we could avoid this wrapping
return createCaseExpression(treatedPath.getWrappedPath(), treatedPath.getTreatTarget(), expression);
}
return expression;
}
Aggregations