本文介绍了JPA本机查询和缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
JPA(createNativeQuery
)中的本机查询是否支持缓存?
我要填充自己的数据传输对象,因为sql查询会联接多个表,并且仅从表中获取几列.
Does native query in JPA (createNativeQuery
) supports caching?
I am filling my own data transfer object because the sql query joins several tables and takes only several columns form them.
致谢
推荐答案
这是可能的,但是您必须使用显式的.addScalar
或.addEntity
.
This is possible but you must use an explicit .addScalar
or .addEntity
.
- Caching SQL query problem
- Hibernate: Truly Understanding the Second-Level and Query Caches
这篇关于JPA本机查询和缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!