one-to-one non-lazy loading but Filters Not Applied.
posted 7 years ago
We all know that one-to-one associations are non-lazly fetched but during this fetching the filters are not applied.
I debugged hibernate code and found that hibernate finally calls EntityLoader.loadByUniqueKey() method:
I can understand that why filters are not applied because all one-to-one association is automatically non-lazyly fetched
and user may not have specified to fetch this associations and hence not enabled corresponding filters on session and also
not provided filter parameters.
For my case it is very important that i always apply filter as in my case if i don't apply filters, it will return me more than one record as i have one-to-one assocition at Domain model level but
same association is one-to-many at database level and by applying filter i make this one-to-many association at database level as
one-to-one association at Domain model.
Is there somehow, i can apply filters always to one-to-one association or better don;t even create a proxy of one-to-one assocaitons that
i have not asked for?