We have a requirement that is really begging that each customer have it's own database. All the databases will have an identical schema. We would, of course, need to have a session factory configured for each database. However, there could be upward of 100 separate databases. Ideally, having all 100 session factories build on system startup makes things easy programatically. However, I'm concerned about needless overhead.
Because of this, I'm leaning toward keeping a pool of Session Factories and only creating them when needed, e.g. when a user needs to access their database (typically on login) it will create that session factory and add it to a "pool."
I've read through some forums in various locations and some suggest it's a bad idea to have more than one session factory. Hibernate supports it. I am concerned about the memory overhead and # of connections to the database. At first I think the pool for each would be 2-4 connections each. I realize this means that with 100 databases this is 400 connections and I'm not comfortable with that.
Does anybody have any thoughts on this one way or another?
|