gpt4 book ai didi

java - 又名获取计划。获取组又名。 QueryDSL 中的实体图

转载 作者:行者123 更新时间:2023-11-29 07:04:28 25 4
gpt4 key购买 nike

我无法找到任何在 QueryDSL 中实现获取计划的方法,我尝试了很多。你能给我任何提示吗?此外,您是否知道在不同情况下选择要获取哪些字段以及延迟加载哪些字段的更好方法?我使用批量抓取,因此无法使用 JOIN FETCH。

最佳答案

像这样的 EntityGraph 定义

@NamedEntityGraph(
name = "post",
attributeNodes = {
@NamedAttributeNode("title"),
@NamedAttributeNode(value = "comments", subgraph = "comments")
},
subgraphs = {
@NamedSubgraph(
name = "comments",
attributeNodes = {
@NamedAttributeNode("content")}
)
}
)

EntityGraph 实例可以像这样在 Querydsl 查询中被激活

EntityGraph postGraph = em.getEntityGraph("post");
query.setHint("javax.persistence.fetchgraph", postGraph)

来源:http://hantsy.blogspot.fi/2013/12/jpa-21-entity-graph.html

关于java - 又名获取计划。获取组又名。 QueryDSL 中的实体图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21405897/

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