OpenFeign / querydsl

Unified Queries for Java
https://querydsl.com
Apache License 2.0
238 stars 37 forks source link

[BUG] Collection .contains() not working anymore #377

Closed H-Lo closed 1 hour ago

H-Lo commented 6 months ago

The bug I raised 5 months ago is not fixed in 6.1 or 6.2:

https://github.com/querydsl/querydsl/issues/3618

H-Lo commented 5 months ago

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. Switched to my own stored procedure to do the job properly but still hoping this will be fixed one day in the future.

OrangeDog commented 4 months ago

I don't think this is a bug. This is caused by you providing an incomplete custom mapping.

The roles property is a Set, so member of is the correct JPQL to use. You are providing a Set <-> TEXT converter, but no matching implementation for the member of operator.

Hibernate 6 added a lot more checks and validation to its query processing, so it won't allow this type mismatch any more.

What was the generated SQL for them before? I cannot see how they would have ever worked properly.

H-Lo commented 4 months ago

@OrangeDog Hi! That worked before for sure, but if there was a bug in earlier releases, I managed it to work with those converteds and annotations. I'm not claiming this should work again, the idea is to report a bug as a radical behaviour change. Generated SQL statements are presented here: https://github.com/querydsl/querydsl/issues/3618#issuecomment-1867621756

OrangeDog commented 4 months ago

@H-Lo those are the JPQL queries, not the SQL queries.

I don't think there was any change in QueryDSL, radical or otherwise. It was a change in Hibernate.

H-Lo commented 4 months ago

My bad. I give up on this, I wrote stored procedures and now using them instead and I can live with it. If you have a hint what to do with my code to fix it, I can give it a try.

OrangeDog commented 4 months ago

matching implementation for the member of operator

https://docs.jboss.org/hibernate/orm/current/userguide/html_single/Hibernate_User_Guide.html#bootstrap-jpa-metadata

You may also find it useful to create a custom QueryDSL method, to generate a different JPQL than member of.

As I don't know what SQL you are expecting to work to achieve this query, I cannot help further.

If you can change your schema, I would use a native ARRAY type, which has full JPA support in Hibernate via the array_contains function.

velo commented 1 hour ago

Seems no one is working on this, I'm closing to clear the board. Feel free to reopen after a PR is submitted.