Quote:
1) In JDBC we use Connection class to communicate with database. We make use of DriverManager.
In hibernate we configure a datasource and we get a session object.
What is the difference between the Connection class and the Session class. Please let me know the similarities and differences.
That's a big question, I'm going to be short as the complete answer would require me to re-write our documentation or books.
A Connection is basically just a handle to a "channel", commands you send are executed right away. A Session is stateful, it caches information that you might ask again (you get the same object reference if loading the same entities multiple times), and it "queues up" changes you want to apply to the database but postpones them in efficient batched prepared statements, possibly reordering them and merging several operations, to the flush or commit time.
Quote:
What it means actually with respect to connections . In a transaction, we do open and close session objects in code. When we open a session, does it mean the min pool size reduces by X-1 ?? and when we close how many connections are available.
Opening a Session doesn't open a Connection, but a Session might need to briefly open and release a connection for short times if it needs so. Generally it makes it possible to reuse connections in a more efficient form. Isolation levels and running are maintained.