Query to update by composite ids in collection works for multiple ids, but for empty collection against MySQL, bad query gets generated ends up being below (Captured by debugging org.hibernate.query.internal.AbstractProducedQuery#doExecuteUpdate )
ย
Which later causes error:
We have entity with composite key, and then we have another table of that to hold our LOB columns to avoid loading them unnecessarily.
We want to be able to null out the jsonContent without having to load the entity (and the large column), so we wrote a query
This works fine in our test environment against h2 database, but against mysql, when ids is empty, get error explained above. works as long as there is 1 or more items in the collection.
hibernate-core-5.4.23.Final
java version "11.0.8" 2020-07-14 LTS
groovy 2.5.13-indy
8.0.19 (MySQL Community Server - GPL)
Windows 10 64bit
Just donโt call the method then if the ids list is empty. That way you also avoid hitting the database. FWIW this is fixed in Hibernate 6 which is currently under development.
Ah thanks, eventually found that workaround too. Took many hours debugging because of the mysql/h2 difference so thought good to log hopefully next person to have same problem can easily find this issue and workaround
This was reported a few times already
Iโll close this issue then