我无法在QueryDSL中找到任何实现获取计划的方法,我尝试了很多.你能给我任何提示吗?另外,你知道更好的方法来选择要获取哪些字段以及在不同情况下懒散加载哪些字段?我使用批量提取,因此我不能使用JOIN FETCH.
使用像这样的EntityGraph定义
@NamedEntityGraph(
name = "post",
attributeNodes = {
@NamedAttributeNode("title"),
@NamedAttributeNode(value = "comments", subgraph = "comments")
},
subgraphs = {
@NamedSubgraph(
name = "comments",
attributeNodes = {
@NamedAttributeNode("content")}
)
}
)
Run Code Online (Sandbox Code Playgroud)
该EntityGraph实例可以这样被激活的Querydsl查询
EntityGraph postGraph = em.getEntityGraph("post");
query.setHint("javax.persistence.fetchgraph", postGraph)
Run Code Online (Sandbox Code Playgroud)
来源:http://hantsy.blogspot.fi/2013/12/jpa-21-entity-graph.html
| 归档时间: |
|
| 查看次数: |
2367 次 |
| 最近记录: |