java - 使用 Spring Data JPA 和 Stream 的休眠查询缓存不起作用
问题描述
我在我的 Spring Data JPA 存储库上使用 Hibernate 查询缓存,如果我使用 List 作为返回类型,一切正常,如果我使用 Stream 似乎休眠不缓存结果:
不工作的代码:
@Query("select E from Entity E where E.id = :id E.name asc")
@QueryHints({@QueryHint(name = "org.hibernate.cacheable", value = "true")})
Stream<Entity> getProvinceList(@Param("id") String id);
工作代码:
@Query("select E from Entity E where E.id = :id E.name asc")
@QueryHints({@QueryHint(name = "org.hibernate.cacheable", value = "true")})
List<Entity> getProvinceList(@Param("id") String id);
在客户端代码中关闭或不关闭流没有区别。
有人有同样的问题吗?实际上我解决了使用列表并将其转换为客户端代码中的流。
解决方案
推荐阅读
- typescript - 如何处理 axios httpservice 可观察响应?
- r - 将 lat 和 long 数据帧转换为 R 中的多个空间多边形
- prometheus - 如何在 Prometheus jmx-exporter 中将属性转换为标签?
- java - 如何对两种不同的文件格式运行单元测试?
- django - 如何将视图功能与 django 中的两个模板连接起来?
- node.js - 为什么不使用 NodeJS 中的 API 就无法获取所有 Instagram 帖子
- ansible - Ansible 调试消息到变量
- linux - 背景和顶栏配置在启动时不适用
- python - 有没有办法强制随机森林回归器不适合截距?
- vst - 无法让任何声音驱动程序为 Samplitude 工作