I am experiencing strange behavior in the process of upgrading to Hibernate 6.x. It seems {{@Where}} annotation on entity class is ignored when using with entity graph or fetch join. Despite the same entity classes and queries, wrong SQL is generated after upgrading to Hibernate 6.x, which is not what I expected.
I have created a sample project to test the issue and show the situation in detail. Here is GitHub repository for the sample project:
* Sample project (with Hibernate 5.6.14.Final): [ GitHub - https://github.com/ dev-jaehoonlee/hibernate-orm-demo at /tree/ hibernate-5.6|https://github.com/dev-jaehoonlee/hibernate-orm-demo/tree/hibernate-5.6 |smart-link ] * Sample project (with Hibernate 6.1.6.Final): [ GitHub - https://github.com/ dev-jaehoonlee/hibernate-orm-demo at /tree/ hibernate-6.1|https://github.com/dev-jaehoonlee/hibernate-orm-demo/tree/hibernate-6.1 |smart-link ]
I have explained the details on discourse topic - [https://discourse.hibernate.org/t/where-clause-ignored-after-upgrading-to-hibernate-6/7120|https://discourse.hibernate.org/t/where-clause-ignored-after-upgrading-to-hibernate-6/7120|smart-link]
I also forked hibernate-test-case-templates repository and added test cases: [https://github.com/dev-jaehoonlee/hibernate-test-case-templates/tree/HHH-16019|https://github.com/dev-jaehoonlee/hibernate-test-case-templates/tree/HHH-16019|smart-link]
[orm/hibernate-orm-5/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java|https://github.com/dev-jaehoonlee/hibernate-test-case-templates/blob/HHH-16019/orm/hibernate-orm-5/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java] and [orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java|https://github.com/dev-jaehoonlee/hibernate-test-case-templates/blob/HHH-16019/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java] have the same test cases, but tests are passed with Hibernate 5.6 and failed with Hibernate 6.1 |
|