June 28, 2011 §
I find JPA and in particular EclipseLink 2.3 to be particularly well suited to illustrate the concept of multitenancy, one of the key PaaS features en route for Java EE 7.
Here’s a short (5-minute) screencast showing GlassFish 3.1.1 (due out real soon now) and its EclipseLink 2.3 JPA provider showing multitenancy in action. In short, it adds EclipseLink annotations to a JPA entity and deploys two identical applications with different
tenant-id properties defined in the
persistence.xml descriptor. Each application only sees its own data, yet everything is stored in the same table which was augmented with a discriminator column.
For more advanced (or more realistic) uses such as tenant property being set on the
@PersistenceContext, XML configuration of multitenant JPA entities, and more check out the nicely written wiki page.