gpt4 book ai didi

java - Hibernate 5.2后如何使用 `setResultTransformer`?

转载 作者:IT老高 更新时间:2023-10-28 20:35:58 29 4
gpt4 key购买 nike

我想用 query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP)获取 List<Map> .但我有一个异常(exception):

java.lang.NoSuchMethodError: org.hibernate.query.Query.setResultTransformer(Lorg/hibernate/transform/ResultTransformer;)Lorg/hibernate/Query;

我找不到 org.hibernate.query.Query 的实现类.方法setResultTransformerorg.hibernate.Query .

为什么不推荐使用 org.hibernate.Query?

最佳答案

The ResultTransformer comes with a legacy definition which is not following the Functional Interface syntax. Hence, we cannot use a lambda in this example. Hibernate 6.0 aims to overcome this issue, so that’s why the Hibernate ORM 5.2 ResultTransformer is deprecated. Nevertheless, an alternative will be provided, so the concept we are discussing in this article is going to stand still even in Hibernate 6.

https://vladmihalcea.com/why-you-should-use-the-hibernate-resulttransformer-to-customize-result-set-mappings/

关于java - Hibernate 5.2后如何使用 `setResultTransformer`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38240015/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com