New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Collection .contains() not working anymore #3618
Comments
migrate to jpa specifications. This project is abandonware. |
@H-Lo doubt you will get any help here. I tried to volunteer... but what the present team is looking for is NOT someone to keep the project active Since there is a conscientious choice to get this project on a death spiral, I forked it and start my own release cycles https://github.com/OpenFeign/querydsl There are 3 releases out already, latest one with first contributions from opensource.
@danielvion and myself are preparing for a major push towards querydsl 6.0 with hibernate 6 support. At this stage, we are looking for volunteer to try it out. |
agreed, that is why I forked it. |
There are some major incompatibilities when it comes to the JPA module and hibernate 6. I am currently working on migrating to hibernate 6 in the fork mentioned above. https://github.com/OpenFeign/querydsl At the moment everything compiles and the tests are running. I am testing the changes in my project (big monolith with 400k lines of code) and I have found some further compatibility problems. I am working of fixing that, but afterwards some more testing will be appreciated, especially in different contexts. Hibernate changed the way their type mappings work and also a lot of other implementation details have changed when it comes to ResultItterators for example. Maybe you can clone the fork and test with the updated version? |
Oh my.... This is pretty unclear situation for me as a consumer of dependecies. @danielvion @velo I will give it a try and hope it will be appropriate to continue with. I don't like queries in String because there is more chance to have an error not detected at design time. |
If anyone else reads this, here are the Maven repo links: |
@danielvion @velo Ok, I managed to replace original QueryDSL dependency with 5.1.1 but I get the same error as I did before (which I know is expected because you're not ready for Hibernate 6). BR, |
I'm gonna try to get some sort of 6.0 release candidate out today. Let's see how that goes |
I released a milestone to maven central Give |
Tried version |
For those who came here and want to get rid of abandoned QueryDSL, here is a simple example how to switch to Criteria API. Criteria API is extremely ugly by syntax but it still works comparing to Query DSL. Query DSL
Criteria API
|
Another example Query DSL
Criteria API
|
@H-Lo |
@velo Thanks! I'll give it a shot for sure because Criteria API is created for masochists 😢 |
@velo Bad news for me. Upgraded to 6.0.0.M2 but exceptions from my original question are still thrown - for both cases: Is there a way to write those queries in different way to comply with syntax? |
@velo I am aware it's Hibernate thing because Hibernate obviously did something to break QueryDSL, but I guess I cannot ask Hibernate team to make modifications to comply with old abandoned project. |
@H-Lo I will try to do some more debugging into the issue. I will try to reproduce it in the querydsl tests. At the moment all the tests are running using hibernate 6, but I am not sure if there are any for the contains() or any() on the collections. |
@danielvion Thanks a million! I can help if you want. I can try to put some breakpoints, inspect and send you results or line numbers where this issue happens or even try to create runnable minimalistic test case if nothing else helps. |
I will be working on the fork https://github.com/OpenFeign/querydsl to reproduce the issue. A minimalistic failing test case would be great for me to use as a starting point. I am not sure if we should leave out spring since I believe this is more of a hibernate related issue. |
@danielvion Hi! Please try with this one that I created just now: https://github.com/H-Lo/QueryDSLContainsBug |
I cloned the repository and had a look at the errors. It doesn't seem straightforward to fix. I will try to reproduce the errors in the querydsl repository as some unit tests and fix it there. Hibernate 6 changed the way the types of the query parameters get validated, I believe this is what is causing the issues now. |
Today I did an experiment - wrote the same query in 3 ways: by using QueryDSL, HQL and stored procedure on MySQL database.
|
I managed to reproduce it here... So, seems querydsl translates So, there will be need to change the apt tool and the jpql query serializer. |
@H-Lo can you confirm if OpenFeign/querydsl#173 adequately reproduces the issue you are communicating? |
@velo Hi! Please accept my apologies because I'm not sure what should I confirm. Just to clarify - should I clone the whole QueryDSL on my local computer and try it instead the one from Maven repository? No problem to me, but please give me a bit more info on what to do. Thanks and sorry for possible misunderstanding. |
@H-Lo just want to know if the jpql query looks correct: |
@velo Hi! Thank you for explanation! case #1 - The query generated by using
case #2 - The query generated by using
|
Just to mention that I tried with |
Just to mention that I tried with |
Just to mention that I tried with com.querydsl 5.1.0 and openfeign.querydsl 6.2.1 published on Apr 09, 2024 and the bug is still there. |
Observed vs. expected behavior
The query that I wrote in the past previously was working with older Hibernate, now is not working.
Steps to reproduce
In the repository classes there are 3 methods and none of those is working:
[UserRepositoryImpl] findByUserRole_1()
[UserRepositoryImpl] findByUserRole_2() Alternate
where
clause also throws exception:[UserRepository] findByUserRole_3() This one also used to work and now throws exception:
UserRole.java
User.java
UserRepositoryImpl.java
UserRepository.java
UserRolesConverter.java
Environment
OS: Windows 11 Pro 23H2 22631.2506 Windows Feature Experience Pack 1000.22677.1000.0
IDE: Eclipse STS Version: 4.20.1.RELEASE Build Id: 202310260003 Revision: b4f357cb0399519f520df4fc968315d5735367da
Spring: Spring Boot 3.1.5
Hibernate: Hibernate ORM 6.3.1.Final
Querydsl version: 5.0.0
Querydsl module: querydsl-apt, querydsl-jpa, com.querydsl.apt.jpa.JPAAnnotationProcessor
Database: mysql Ver 8.0.16 for Win64 on x86_64 (MySQL Community Server - GPL)
JDK: openjdk version "17.0.7" 2023-04-18 OpenJDK Runtime Environment Temurin-17.0.7+7 (build 17.0.7+7) OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (build 17.0.7+7, mixed mode, sharing)
See also
https://stackoverflow.com/questions/77409442/querydsl-collection-contains
The text was updated successfully, but these errors were encountered: