Here is a test case and my proposed fix: https://github.com/hibernate/hibernate-orm/compare/master...barreiro:HHH-10533