Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » Multi-tenancy and @PersistenceContext
Multi-tenancy and @PersistenceContext [message #732046] Mon, 03 October 2011 14:42
Eclipse UserFriend
Hello,

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()) {
session.setProperty(...);
}
}


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.

Thanks!
--Bill
Previous Topic:Multi-tenancy and @PersistenceContext
Next Topic:@Embeddable with Entity relations
Goto Forum:
  


Current Time: Wed Jul 23 08:18:43 EDT 2025

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

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

Back to the top