users@glassfish.java.net

multi-tenant JPA and GlassFish/EclipseLink?

From: Gregory Gerard <ggerard_at_mac.com>
Date: Wed, 01 Sep 2010 23:18:32 -0700

Any guidance for doing multi-tenant setups with GlassFish v3.[01]?

Options:
1. add a column to just about every table for the customer identity and make sure it's part of every query and update.
-- requires every developer to do the right thing and pass in the customer identity.

2. devote a webapp per customer so it can be bound to that customer's proper database and schema. doesn't preclude mixing in #1.
-- each appserver needs quite a number of webapps but is more secure than relying on every developer doing the queries right.

3. use one webapp but magically pass through the customer id somehow and have it used to find the DataSource
-- use something from the login screen to lookup the customer info to then lookup a JNDI name and then have JPA use that.
-- even possible?
-- schemas and versions need to be carefully coordinated with each upgrade

How does VPD do it and would it be worth the cost? Are the above doable?

http://wiki.eclipse.org/index.php?title=EclipseLink/Examples/JPA/Oracle/VPD

Is of course empty...

thanks,
greg