-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi all!
I wrote a workaround to map multiple database with hibernate.
My modified HibernateUtil class uses a map to store all the SessionFactories, using the hibernate configuration filename as key.
The hibernate configuration filenames are set in zk.xml, as follows:
<preference> <name>HibernateUtil.config</name> <value>hibernate.cfg.xml,other.cfg.xml</value> </preference>
My HibernateUtil.currentSession() get the hibernate session related to first hibernate configuration file, and I provide a new HibernateUtil.currentSession(String configFile) method that gets an hibernate session related to the hibernate configuration filename "configFile".
For example, to get a session related to other.cfg.xml in the example above, you have to code something like this:
HibernateUtil.currentSession("other.cfg.xml");
Sources are here: org.alessi.zk.hibernate.zip and contains a modified version of:
HibernateSessionFactoryListener
HibernateUtil
OpenSessionInViewListener
All seems to work fine for me.
Any suggestion? Can you test it?
Hi, Firstly, my apologies for posting on an old thread, but I have just been asked to add exactly this functionality to an existing application. The link in the above post is now out of date so can I ask if anyone has the sources provided could they please post a new link or maybe send them to me.
Many thanks, Keith
Have a look at the EmptyInterceptor class from Hibernate.
I have already done this. wait until this week end, i will write down the steps in my blog.
i need help a lot :< i cant make it through
Asked: 2011-10-02 08:19:04 +0800
Seen: 889 times
Last updated: Nov 14 '14