Reputation: 6236
How to use select straight_join ... from ...
in hibernate/jpa?
Upvotes: 4
Views: 1397
Reputation: 41
It should be possible in the Hibernate 5.2.12 and MySQL version 8 using optimizer hint JOIN_FIXED_ORDER (the same effect as STRAIGHT_JOIN) More information available under the links:
Jira ticket: https://hibernate.atlassian.net/browse/HHH-11906
Hibernate code change that allows this: https://github.com/hibernate/hibernate-orm/commit/72506a6eacc367297a3205f6e1fec7ccbc153799
Documentation for MySQL Optimizer hints: https://dev.mysql.com/doc/refman/8.0/en/optimizer-hints.html
Upvotes: 4
Reputation: 1912
There is no straight_join for JPQL/JPA.
You will need to use it in NativeQuery.
entityManager.createNativeQuery(...);
Upvotes: 5