>Now if the application is multiuser and the DB Connections would be >used on above basis i.e. each user opens the connection in there own >requests and never close it, than you would be short of DB Connections. >And you know the consequences if there are no Connections to DB.
I am thinking that connections are multiplexed.. meaning with single connection one could excute mutiple statements. This way having single session seems to be better..
Yes, if all the connections are not released, then it could be a big issue. However, my intention is use single session and let session manage the connection managment and release.. As a programmer, I don't want to work on connection level, instead I would only say some query to be executed and transaction to be opened and commited etc.
I am hoping to more on session and its scope other than mapping this to just to connection holder..
Regards,
Nagendra
waswani wrote:
Every time you want to work with any Database, you need to obtain a connection. In Hibernate you configure the DB properties in the .properties OR .xml file.
Whenever you create a Session, internally a DB Connection object is created and till you close the session, the connection would be open.
Now if the application is multiuser and the DB Connections would be used on above basis i.e. each user opens the connection in there own requests and never close it, than you would be short of DB Connections. And you know the consequences if there are no Connections to DB.
On the other hand, Transation is something for us to describe what is the Unit of Work that we want. For ex...lets says
For ex...lets say...I have a Unit of Work defined for Shopping App.
After user enters the Credit Card Info ----- verify the card info , deduct the amount from his account -----put the amount into the merchant account ---- update the inventory ----- send a mail or message to the User about the same.
Now, I can make use of session to update the DB but to do other tasks, I need to make use of Transaction..so that they become as one unit of work....either all tasks should happen OR nothing should happen.
I hope you would be clear with this. Let me know if you have any concerns.