Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate 使用SQL提示强制使用querydsl索引_Hibernate_Jpa_Querydsl - Fatal编程技术网

Hibernate 使用SQL提示强制使用querydsl索引

Hibernate 使用SQL提示强制使用querydsl索引,hibernate,jpa,querydsl,Hibernate,Jpa,Querydsl,在我们的应用程序中,我们将querydsl与JPA一起使用。下面是我的存储库实现的方式: public interface TestRepository extends JpaRepository<Test, Long>, QueryDslPredicateExecutor<Test> { } 为了解决性能问题,我们需要在特定的表上强制索引。现在派生查询如下所示: 从表1 tab1\u中选择tab1.id作为id\u 20\u,tab1.user\u type作为

在我们的应用程序中,我们将
querydsl
与JPA一起使用。下面是我的存储库实现的方式:

public interface TestRepository  extends JpaRepository<Test, Long>, QueryDslPredicateExecutor<Test> {   }
为了解决性能问题,我们需要在特定的表上强制索引。现在派生查询如下所示:

从表1 tab1\u中选择tab1.id作为id\u 20\u,tab1.user\u type作为user\u type2\u 20\u

我们希望我们的查询如下所示:

从表1 tab1中选择/*+索引(tab1\MGS\u KG1)*/tab1\u.id作为id\u 20\u,tab1\u.user作为user\u type2\u 20\u

我怎样才能达到同样的效果?(我们使用的是querydsl jpa 3.6.7)

谢谢

您可以使用

只要调用
super
并修改结果SQL字符串,在
选择
后插入索引字符串,如果
FROM
包含必要的表

testRepository.findAll(booleanBuilder.getValue(), pageable);
public String onPrepareStatement(String sql);