• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getCurrentSession in multi tenancy hibernate implementation

 
Oscar Melo
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
I now am refactoring one hard code client application to multi tenant application. Application is very big and any change is expensive. We are working now developing a component for to select Connection Provider and is working well, but the application used before hibernate 3.5 and contain an implementation for HibernateUtil as like are in many pages for beginners. The problem is the use for getCurrentSession throught sessionFactory, because this method returned current session that was opened previously. Now, using withOptions method only is possible use openSession() (always creates a new session), and we haven't been able to figure how get current session with open new one.
To make me understand, hibernate util looks like below:



So, Session is initialized and a new Transaction is open, Session is never passed back and endTransaction method, for example, uses getCurrentSession to know what session should to close.

I have readed the little documentation from jboss about multitenancy and he tried implementing CurrentTenantIdentifierResolver, but i cant understand how get session open without to change methods returning the Session object and put it into parameters, because this generates thousands of changes.

I appreciate any help or guide. Thanks in advance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic