我无法找到任何在 QueryDSL 中实现获取计划的方法,我尝试了很多。你能为我提供任何提示吗?另外,您是否知道在不同情况下选择要获取哪些字段以及延迟加载哪些字段的更好方法?我使用批量获取,因此无法使用 JOIN FETCH。
使用这样的 EntityGraph 定义
@NamedEntityGraph(
name = "post",
attributeNodes = {
@NamedAttributeNode("title"),
@NamedAttributeNode(value = "comments", subgraph = "comments")
},
subgraphs = {
@NamedSubgraph(
name = "comments",
attributeNodes = {
@NamedAttributeNode("content")}
)
}
)
the EntityGraph
可以在 Querydsl 查询上像这样激活实例
EntityGraph postGraph = em.getEntityGraph("post");
query.setHint("javax.persistence.fetchgraph", postGraph)
source: http://hantsy.blogspot.fi/2013/12/jpa-21-entity-graph.html http://hantsy.blogspot.fi/2013/12/jpa-21-entity-graph.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)