-
1. Re: JBoss, Hibernate, Connect to multiple datasources?
yangju Aug 23, 2005 12:00 PM (in response to yoava)I am facing the same problem. I cannot find a good solution. But to get around with this, I had to dynamically clone an existing hibernate sevice mbean (using MBeanServer API) and modify the datasource attribute of the created mbean on the fly. I keep all other attributes untouched (ofcouse you need to assign a unique jmx objectname for this newly created mbean). This way, I only need to define one sessionfactory mbean for one database and create sessionfactories for other datasources on the fly.
I don't think this is the best solution because if you bounce your jboss server, all the dynamically generated sessionfactories will be lost. But this approach works.
Anybody has better idea? The problem facing us is that we only know which datasource to call at runtime. And we don't want to hard code the hibernate session factory.