|
#1
|
|||
|
|||
|
A requirement arose in our application which required us to dynamically toggle the SessionFactory depending on certain conditions/states in our application. To solve this problem we created a lookup for a new service layer to control/manage that data source. However, when it came down to LocalSessionFactoryBean, we ran into a problem since it only ever returns the one instance of the SessionFactory it configured on startup.
I have a solution this problem and after talking with Rod Johnson briefly last night, i determined that even he has found a need for this feature. I have written a blog entry on the topic and have code available here Last edited by mojavelinux; May 19th, 2006 at 12:31 AM. |
|
#2
|
|||
|
|||
|
The question at this point is whether anyone else finds this useful. I would imagine that there are a couple of other folks out there that need to use the same hibernate configuration on different database connections. This usually occur when doing a "round-robin" with a set of database connections or when the same database schema might be populated different depending on environment or region.
I personally feel that this class should make it into spring, perhaps with a couple of modifications. Anyone who is willing to provide feedback, or discuss why this is a useful feature, would be helpful. |
|
#3
|
|||
|
|||
|
Hi,
I found your post very useful, and matter of fact, sent it to a few of my colleagues. However, I've got a question because we're facing a similar situation. One of my colleagues makes a call to the database (Spring /Hibernate 3) and gets a result set. No problem there. However, when a change gets made to the underlying persistence database and we query again, we get an exception because what the session is looking for is no longer valid ( I apologize for my vagueness). Would you consider this to be an issue related to the sessionFactory/LocalSessionFactoryBean Warm regards, |
![]() |
| Thread Tools | |
| Display Modes | |
|
|