• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

getCurrentSession in multi tenancy hibernate implementation

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.
There's a city wid manhunt for this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic