Hi asotobu,
you seem to have misunderstood something.
At first thing we must distinct between lazy loading on collections (=ToMany relations) and
lazy loading on entity references (= ToOne relations).
Only the latter one uses proxies, so the difference turns out only in following scenario:
Code:
Session session = openNewSession();
Bar bar = session.get(Bar.class, barId);
In case that you declare class Foo
non final,
hibernate can fetch the bar instance from database without need to read also its parent foo record,
because bar.foo will be filled with a proxy of Foo containing just the primary key information of that foo.
That proxy is a runtime subclass of class Foo.
In case that you declare class Foo
final,
nobody is allowed to extend Foo, that means nobody can create subclasses of Foo, so hibernate cannot create a proxy for Foo and thus hibernate must load the parent foo instance eagerly. This results in having a second query being executed for fetching that foo record from database.
Hope now its clear.