straight_join in JPA or HIBERNATE

霸气de小男生 提交于 2020-01-13 05:22:10

问题


How to use select straight_join ... from ... in hibernate/jpa?


回答1:


There is no straight_join for JPQL/JPA.

You will need to use it in NativeQuery.

entityManager.createNativeQuery(...);




回答2:


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



来源:https://stackoverflow.com/questions/27782991/straight-join-in-jpa-or-hibernate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!