myenterprize
07-04-2007, 11:26 AM
Apologies if this has been covered in some other post ... but I have gone through almost all the posts and could not get a clear answer!!!
I was looking at the tests in Northwind Sample with NHibernate module, as these are tests OpenSessionInView does not make sense, but where is session Manaagement code? Is it in transaction proxy and interceptor? If yes, how does HibernateTemplate know that there is already a transaction and session is already opened ? AFAIK HibernateTemplate code opens/closes session during each method call. That's why we don’t need to worry about session management when using HibernateTemplate.
Then there is another issue I have been thinking about, if a method in service layer invokes multiple DAO methods (which is almost certainly always the case) and DAO's are built using HibernateTemplate, would not each DAO method invocation result in open session/ close sessions? so if a service method calls 3 DAO methods, there will be 3 open sessions and 3 close sessions????????
So the question I think boils down to.... How does spring ensure only one open session /close session call per service method when DAO's use Hibernate Template and rely on its session management??
I must admit I prefer the easy route of asking somebody to explain something in 2 minutes, which might take me hours to go through the murky world called code.
Thanks
I was looking at the tests in Northwind Sample with NHibernate module, as these are tests OpenSessionInView does not make sense, but where is session Manaagement code? Is it in transaction proxy and interceptor? If yes, how does HibernateTemplate know that there is already a transaction and session is already opened ? AFAIK HibernateTemplate code opens/closes session during each method call. That's why we don’t need to worry about session management when using HibernateTemplate.
Then there is another issue I have been thinking about, if a method in service layer invokes multiple DAO methods (which is almost certainly always the case) and DAO's are built using HibernateTemplate, would not each DAO method invocation result in open session/ close sessions? so if a service method calls 3 DAO methods, there will be 3 open sessions and 3 close sessions????????
So the question I think boils down to.... How does spring ensure only one open session /close session call per service method when DAO's use Hibernate Template and rely on its session management??
I must admit I prefer the easy route of asking somebody to explain something in 2 minutes, which might take me hours to go through the murky world called code.
Thanks