我正在尝试调试 n+1 查询问题,并尝试使用 EntityGraphs 来解决它。
说我有以下查询
@Query("select om.organization from OrganizationMember om")
并且组织有一些额外的字段说“属性”
EntityGraph
优化会应用于选择吗?
@EntityGraph(attributePaths = {
"attributes",
})
@Query("select om.organization from OrganizationMember om")
或者我应该这样做吗?
@EntityGraph(attributePaths = {
"organization.attributes",
})
@Query("select om.organization from OrganizationMember om")