Wouldn't it be reasonable to use a proxy (which might be inconsistent with the DB due to a programming error) and throw an exception when trying to initialize the proxy? Now this could of course give you incorrect behaviour in case of a != null check, but that would be due to incorrect mapping which is a programming error. How do you validate the optional flag of basic properties at runtime (other than throwing an exception when trying to persist an entity that violates this constraint)? Couldn't you do the same validation for one-to-one relations or does this validation somehow require bytecode enhancement? Of course lazy @Basic properties require bytecode enhancement, no question about that. |