Fix for HHH-9419 into master

See https://github.com/hibernate/hibernate-orm/pull/815