Using in Query with collection of composite keys generates invalid query on Mysql with empty collection

Description

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.

Environment

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

Activity

Show:
Christian Beikov
December 17, 2020, 11:35 AM

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.

Nathan McDonald
December 17, 2020, 11:39 AM

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

Christian Beikov
December 17, 2020, 12:08 PM

This was reported a few times already

I’ll close this issue then

Out of Date

Assignee

Christian Beikov

Reporter

Nathan McDonald

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor