Meaningless Drivel is fun!*
The moose likes Spring and the fly likes Pass DB connection on the fly to hibernate session for the DAO based on spring-HibernateDaoSupport Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Pass DB connection on the fly to hibernate session for the DAO based on spring-HibernateDaoSupport" Watch "Pass DB connection on the fly to hibernate session for the DAO based on spring-HibernateDaoSupport" New topic
Author

Pass DB connection on the fly to hibernate session for the DAO based on spring-HibernateDaoSupport

Ammar Fakhruddin
Greenhorn

Joined: Mar 08, 2008
Posts: 2
I am developing an application based on spring hibernate using myeclipse .
I generated Spring DAOs using database explorer and manage to do different DB operations for testing, using a static datasource defined in the applicationContext.xml (NOT THE ONE BELOW)

Now, for the actual application. Each user in my company has his own Oracle user. Therefore it is required to use individual user based connection for any application.
So for each hibernate session I have to create a new oracle connection based on the individual user. Datasources and ConnectionPool does not work here.
(Grrrrr I know, you will not find this in normal applications but this is how our environment works.)

I have generated DAO based on myeclipse and each DAO is extended by default by org.springframework.orm.hibernate3.support.HibernateDaoSupport class which uses getHibernateTemplate() method to execute database operations. Internally HibernateDaoSupport class uses the default session factory as shown in the below applicationContext.xml where I don’t specify the Oracle connection details as I want to pass the connection on the fly.

Is there a way to pass the oracle connection to hibernate session for the generated DAOs?



THANKS
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pass DB connection on the fly to hibernate session for the DAO based on spring-HibernateDaoSupport