Unfortunately, according to the Advanced User's FAQ "You must configure multiple SessionFactory instances" to use multiple DBs.
The way you have described is one way of implementing it (however, I'm not sure why you're 'creating' a sessionFactory and returning it when you're getting a Session). I had the same problem myself once and I ended up making a registry (a map with key = classname and value = sessionFactory (I had each SessionFactory in it's own Class implementing an interface so I can call SessionFactory.getSession() without having to reference a specific SessionFactory)). With this way, you can see if the Object is-a classname and if it is, use the SessionFactory mapped to it.
Hope this helps,
-B
_________________ Please rate me if you found my post useful.
|