[英]Fetch jpa sql execution plan with @QueryHint and spring data repository
I am using spring-data for DB interaction. 我正在使用spring-data进行数据库交互。 I want to see the jpa sql execution plan for a query written in repository. 我想查看在存储库中编写的查询的jpa sql执行计划。 How can i do it. 我该怎么做。
https://vladmihalcea.com/execution-plan-oracle-hibernate-query-hints/ tells about using GATHER_PLAN_STATISTICS and COMMENT query hints. https://vladmihalcea.com/execution-plan-oracle-hibernate-query-hints/讲述了如何使用GATHER_PLAN_STATISTICS和COMMENT查询提示。 I added COMMENT hint but don't know how to add other one. 我添加了COMMENT提示,但不知道如何添加其他提示。
public interface StudentRepository extends JpaRepository<Student, Long>{
@QueryHints({
@QueryHint(name=org.hibernate.annotation.queryHints.COMMENT,
value="SQL_PLAN_STUDENT")
})
List<Student>findByStudentIDIn(List<Long> ids);
}
The @QueryHints
annotation accepts an array constructor like list of @QueryHint
items. @QueryHints
批注接受一个数组构造函数,如@QueryHint
项目列表。
So you can add multiple QueryHints
by addings them to a comma separated list. 因此,您可以通过将多个QueryHints
添加到以逗号分隔的列表中来添加它们。 For example: 例如:
@QueryHints({
@QueryHint(name=org.hibernate.annotations.QueryHints.COMMENT, value="SQL_PLAN_STUDENT"),
@QueryHint(name="GATHER_PLAN_STATISTICS" , value="GATHER_PLAN_STATISTICS")
})
Unfortunately I don't have access to a running instance of a oracle dbms, so I can't check the result of the given hint. 不幸的是,我无权访问正在运行的oracle dbms实例,因此无法检查给定提示的结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.