Hi. I'm using hibernate 3.0.5. I have a question that relates to hibernate's architecture:
Why are many-to-one associations never lazy?
One of my classes has a many-to-one association. Hibernate creates a proxy. When I
call a method of the proxy, hibernate reads the object from the database (which is fine),
but each object that is associated with a many-to-one or one-to-one association, too!
I'd have expected hibernate would generate proxies.
Code inspection showed that right at the start the Configuration object reads my
config file. It calls the constructor "ManyToOneType (String name)", which sets lazy
to false. This basically is the reason why many-to-one assocs are never lazy.
But what is the sense? Why is it not possible to configure hibernate in a way the
constructor "ManyToOneType (String name, boolean lazy)" is called with
"lazy == true"?
Am I missing something?
This behaviour makes parts of my application slow, so this is a crucial problem for me.
Please help me in understanding this task.
Thanks in advance.
Erik
|