我们有一个名为HibernateMetadataBuilderContributor的类,它可以在Hibernate 5或Spring Boot 2.7中正常工作。但是当我们迁移到Hibernate 6或Spring Boot 3时,它就无法正常工作了。
public class HibernateMetadataBuilderContributor implements MetadataBuilderContributor {
public static final String STRING_AGG = "string_agg";
public static final String STRING_AGG_ORDER_BY = "string_agg_order_by";
public static final String STRING_AGG_DISTINCT = "string_agg_distinct";
@Override
public void contribute(final MetadataBuilder metadataBuilder) {
metadataBuilder.applySqlFunction(STRING_AGG, new SQLFunctionTemplate(StandardBasicTypes.STRING, "string_agg(?1, ?2)"));
metadataBuilder.applySqlFunction(STRING_AGG_ORDER_BY, new SQLFunctionTemplate(StandardBasicTypes.STRING, "string_agg(?1, ?2 order by ?3)"));
metadataBuilder.applySqlFunction(STRING_AGG_DISTINCT, new SQLFunctionTemplate(StandardBasicTypes.STRING, "string_agg(distinct ?1, ?2)"));
}
}
Hibernate 6 中找不到 SQLFunctionTemplate,有什么替代方案。