I happen to agree with dia100. Here's my argument:
Hibernate states that its architecture "abstracts the application from the underlying JDBC/JTA API and lets Hibernate take care of the details" (Hibernate Reference, section 2.1).
Also, in section 6.5 of the same document, we have: "Collections (other than arrays) may be lazily initialized, meaning they load their state from the database only when the application needs to access it. Initialization happens transparently to the user so the application would not normally need to worry about this".
Ok, now let's analyse my situation here.
When I develop applications, I separate the classes in four layers:
persistence: communicates with the database;
domain: contain the domain objects (beans);
application: implements the application functionality;
Now, say the view asks the application layer for the "list" functionality. The application calls the persistence layer and retrieves a bunch of domain objects, returning them to the view.
As of now, the view can do anything with the objects, including calling methods that should return collections that are marked as lazy-initialized. And it doesn't make sense that it should ask the persistence to reconnect a session to do that, because the view should not even know what a Session is. It should be oblivious to how the persistence is done.
For me, having to reconnect the session is not transparent initialization, because my application DOES have to worry about it. The problem is that you're saying that Hibernate does something it does not.
I'm not asking Hibernate to control my transactions, I just want to be able to disconnect the Session (to free resources) an be able to, later on, retrieve a collection lazilly without having to explicitly reconnect() something at the persistence layer.
Do I make any sense at all?
Thanks for any replies,
V