use of org.hibernate.sql.ast.tree.expression.ConvertedQueryLiteral in project hibernate-orm by hibernate.
the class BaseSqmToSqlAstConverter method visitEnumLiteral.
@SuppressWarnings({ "raw", "unchecked" })
@Override
public Object visitEnumLiteral(SqmEnumLiteral<?> sqmEnumLiteral) {
final BasicValuedMapping inferrableType = (BasicValuedMapping) resolveInferredType();
if (inferrableType instanceof ConvertibleModelPart) {
final ConvertibleModelPart inferredPart = (ConvertibleModelPart) inferrableType;
final BasicValueConverter<Enum<?>, ?> valueConverter = inferredPart.getValueConverter();
final Object jdbcValue = valueConverter.toRelationalValue(sqmEnumLiteral.getEnumValue());
return new QueryLiteral<>(jdbcValue, inferredPart);
}
final EnumJavaType<?> enumJtd = sqmEnumLiteral.getExpressibleJavaType();
final JdbcType jdbcType = getTypeConfiguration().getJdbcTypeRegistry().getDescriptor(SqlTypes.TINYINT);
final BasicJavaType<Integer> relationalJtd = (BasicJavaType) getTypeConfiguration().getJavaTypeRegistry().getDescriptor(Integer.class);
final BasicType<?> jdbcMappingType = getTypeConfiguration().getBasicTypeRegistry().resolve(relationalJtd, jdbcType);
return new ConvertedQueryLiteral(sqmEnumLiteral.getEnumValue(), new OrdinalEnumValueConverter<>(enumJtd, jdbcType, relationalJtd), jdbcMappingType);
}
Aggregations