master PR: https://github.com/hibernate/hibernate-orm/pull/1312
Gail Badner Could you please cherry-pick fix to 5.0? Thanks