querydsl icon indicating copy to clipboard operation
querydsl copied to clipboard

[BUG] Collection .contains() not working anymore

Open H-Lo opened this issue 1 year ago • 6 comments

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 avatar Apr 10 '24 15:04 H-Lo

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.

H-Lo avatar Apr 30 '24 00:04 H-Lo

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.

OrangeDog avatar Jun 04 '24 13:06 OrangeDog

@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

H-Lo avatar Jun 04 '24 20:06 H-Lo

@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.

OrangeDog avatar Jun 04 '24 21:06 OrangeDog

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.

H-Lo avatar Jun 04 '24 21:06 H-Lo

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.

OrangeDog avatar Jun 04 '24 21:06 OrangeDog

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

velo avatar Oct 18 '24 11:10 velo