Community   SpringSource   Projects    Downloads    Documentation    Forums    Training   Exchange   Blogs

Go Back   Spring Community Forums > Core Spring Projects > Data Access

Reply
 
Thread Tools Display Modes
  #1  
Old May 18th, 2006, 12:35 PM
mojavelinux mojavelinux is offline
Junior Member
 
Join Date: May 2006
Posts: 4
Default A SessionFactory Prototype Solution

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.
Reply With Quote
  #2  
Old May 23rd, 2006, 10:08 PM
mojavelinux mojavelinux is offline
Junior Member
 
Join Date: May 2006
Posts: 4
Smile a real factory

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.
Reply With Quote
  #3  
Old Aug 7th, 2006, 09:15 AM
Josh Josh is offline
Junior Member
 
Join Date: Apr 2006
Posts: 9
Default

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,
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 08:08 AM.


Contegix provides first-class managed hosting and partial sponsorship of these forums.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.