I have created a test case for this bug with Mysql at
https://github.com/stoty/HHH-5998-TestCase
It uses Mysql, but the bug seems to be dialect independent, the same query is generated for H2 and Mysql, only H2 accepts it and Mysql does not.