【发布时间】:2016-10-14 07:58:45
【问题描述】:
我们在应用程序中使用 querydsl 和 JPA。以下是我的存储库实现方式:
public interface TestRepository extends JpaRepository<Test, Long>, QueryDslPredicateExecutor<Test> { }
我正在使用谓词构建器和可分页对象调用默认的 findAll 方法:
testRepository.findAll(booleanBuilder.getValue(), pageable);
为了解决性能问题,我们需要在特定表上强制索引。现在派生查询如下所示:
SELECT tab1_.id AS id_20_, tab1_.user_type AS user_type2_20_ FROM table1 tab1_
我们希望我们的查询看起来像这样:
SELECT /*+ INDEX(tab1_ MGS_KG1) */ tab1_.id AS id_20_, tab1_.user_type AS user_type2_20_ FROM table1 tab1_
我怎样才能达到同样的效果? (我们使用的是 querydsl-jpa 3.6.7)
谢谢!
【问题讨论】: