Multi-tenancy and @PersistenceContext [message #732036] |
Mon, 03 October 2011 18:42 |
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03613 seconds