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.