Potential mysql bug in Hibernate 5.4.11-Final

Hello,

I’ve noticed an issue in mysql and mariadb going from hibernate 5.4.10 to 5.4.11
This issue still exists also in the most recent 5.4.17

It looks like extra parentheses are added to the select columns corresponding to an “collection IS NOT EMPTY” check in JPQL, where the collection is a @OneToMany with mappedBy. Mysql doesn’t like these added parens. The query originally in 5.4.10 came out as

select * from a where not (exists (
select collection.a_id, collection.b_id from collection where a.id = collection.a_id));

But in 5.4.11 it resolves to

select * from a where not (exists (
select (collection.a_id, collection.b_id) from collection where a.id = collection.a_id));

The added parens in the subquery result in this error

Jun 14, 2020 5:41:16 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARNING: SQL Error: 1241, SQLState: 21000
Jun 14, 2020 5:41:16 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
SEVERE: Operand should contain 1 column(s)

I am wondering if this is a known issue, I can give more info if needed. Thanks!

1 Like

I can confirm this issue after updating from 5.4.10 to 5.4.17 with “collection IS EMPTY”, i get the same error.

Hi, just wondering if I can file this somewhere so it can get triaged. Thanks

I filed a bug entry with testcase here. Please vote for it if you’re having this problem for mysql

https://hibernate.atlassian.net/browse/HHH-14134