Using SQL hint to Force Index using querydsl

248 views
Skip to first unread message

Vijay Makhija

unread,
Oct 13, 2016, 3:12:25 AM10/13/16
to Querydsl
Hi,

We are using querydsl with JPA in our application. Below is how my repository implementation:

public interface TestRepository  extends JpaRepository<Test, Long>, QueryDslPredicateExecutor<Test> {   }

I am calling default findAll method using predicate builder and pageable object:

testRepository.findAll(booleanBuilder.getValue(), pageable);


In order to address performance issues, we need to force index on the specific tables. Right now derivative query looks as below:

SELECT tab1_.id AS id_20_, tab1_.user_type AS user_type2_20_ FROM table1 tab1_

And we want our query to look as this:

SELECT /*+ INDEX(tab1_ MGS_KG1) */ tab1_.id AS id_20_, tab1_.user_type AS user_type2_20_ FROM table1 tab1_


How can I achieve the same? (we are using querydsl-jpa 3.6.7)

Thanks!
Reply all
Reply to author
Forward
0 new messages