| I'm seeing something similar in Hibernate 5.1.4. My schema looks like this:
So the thing property is optional for SubA and mandatory for SubB. Here's the problem. This query always returns null even if the object exists:
The reason is that Hibernate generates an INNER JOIN to the Thing table, even though that reference is optional for SubA instances. It's as if the @NotNull constraint is going "up" the class hierarchy from SubB, to Super, and back down (?) affecting sibling class SubA. It seems like a simple rule has been broken: JSR 303 validation constraints should apply downward in the class hierarchy, but never upward! |