It would be straight forward to add a join on the id column of the
foreign table. That would permit Hibernate to discover whether an
optional one-to-one object was present and have enough info to create
the proxy. I have a one-to-one where the foreign table is very large and
holds a bunch of infrequently used information. Most parent records do
not need a detail record as they do not have any of the information it
stores. Parent records are cached and heavily used. It would be a waste
to fill up memory or table space with mostly unused detail records.
If Hibernate would generate an outer join on just the id of the detail
table when retreiving a parent, it could determine at minimal cost
whether there was a detail record or not and so know whether to create a
proxy or not. While going ahead and retrieving the whole detail record
at the same time might be faster in terms of SQL execution, it is still
the wrong thing when the detail record will most likely not be accessed
and is just using up a lot of resources. In fact it was created in the
first place to avoid using up these resources.
Douglas |