再次获取计划.取组又名. QueryDSL中的实体图 [英] Fetch plan aka. fetch group aka. entity graph in QueryDSL
本文介绍了再次获取计划.取组又名. QueryDSL中的实体图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我找不到在QueryDSL中实现获取计划的任何方式,并且尝试了很多.你能给我任何提示吗?另外,您是否知道在不同情况下选择要提取的字段和延迟加载的更好的方法?我使用批量提取,因此无法使用JOIN FETCH.
I was unable to find any way of implementing fetch plans in QueryDSL, and I tried a lot. Can you provide me any hints? Also, do you know any better way of chosing which fields to fetch and which load lazily in different situations? I use batch fetching, therefore I can't use JOIN FETCH.
推荐答案
具有这样的EntityGraph定义
With an EntityGraph definition like this
@NamedEntityGraph(
name = "post",
attributeNodes = {
@NamedAttributeNode("title"),
@NamedAttributeNode(value = "comments", subgraph = "comments")
},
subgraphs = {
@NamedSubgraph(
name = "comments",
attributeNodes = {
@NamedAttributeNode("content")}
)
}
)
可以在Querydsl查询中像这样激活EntityGraph
实例
the EntityGraph
instance can be activated like this on the Querydsl query
EntityGraph postGraph = em.getEntityGraph("post");
query.setHint("javax.persistence.fetchgraph", postGraph)
来源: http://hantsy.blogspot.fi/2013/12/jpa-21-entity-graph.html
这篇关于再次获取计划.取组又名. QueryDSL中的实体图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文