I am referring this link https://developer.jboss.org/wiki/SomeExplanationsOnLazyLoadingone-to-one to understand why lazy loading doesn't work with one to one but works with one to many.
I don't understand why SET object is never null in case of one to many as said in the above link.Can someone please explain?
I still don't understand why lazy loading works in one to many but not in one to one associations.Please explain.
To be honest, I didn't even know about this until now, but this is how I understood that article.
For
@OneToManyHibernate creates a wrapper for the set, and that wrapper is never null. So, if there is no data on the other side, it will just be an empty set, while still being not null.But for
@OneToOnewrapper (proxy) can't be used becausegetCee()(from that article's example) would never return null, which isn't right.nullfor this property means there isn't a matching row in target table,not nullmeans there is. Considering this, wrapper only makes sense if relation is mandatory (constrained=true).