The fix for this was applied a part of PR https://github.com/hibernate/hibernate-orm/pull/2006. An additional test was added for the fix as a part of commit https://github.com/hibernate/hibernate-orm/commit/05f8e7306e340e68e9afa0d39984516f2c38f00e.