Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Multi-tenancy and @PersistenceContext
Multi-tenancy and @PersistenceContext [message #732036] Mon, 03 October 2011 18:42
Bill Schneider is currently offline Bill SchneiderFriend
Messages: 2
Registered: July 2009
Junior Member


What's the best way to use the new @Multitenant support within the standard JavaEE 6 universe?

If I have a JSF or EJB with an EntityManager injected via @PersistenceContext, at what point would I call EM.setProperty("eclipselink.tenant-id")?

I did have some apparent success doing something like this in a session listener:
acquireClientSession(SessionEvent event) { 
  if (event.getSession().isClientSession()) {

Is this a legitimate way to do it? Is it totally wrong, or is there a better way? (With security-related code, I prefer to err on the side of caution.)

A previous attempt to set properties directly on the EM fails, in part because the EM is not a real EM but an EM wrapper class provided by the Glassfish container. (Glassfish 3.1.1 + EclipseLink 2.3 Indigo)

Using multiple EMF's or EM's is not really an option because then we lose all of the
JavaEE standard lifecycle stuff like transaction awareness, making sure the EM's are closed, etc.

Previous Topic:[SOLVED] not recovering a Date field
Next Topic:Multi-tenancy and @PersistenceContext
Goto Forum:

Current Time: Sat Feb 24 06:34:06 GMT 2018

Powered by FUDForum. Page generated in 0.01955 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software