Note: This is likely to be closely related to HHH-9046, which describes a very similar problem when using Hibernate core APIs.