JPA/EclipseLink multitenancy screencast

This blog has moved to alexismp.wordpress.com
Follow the link for the most up-to-date version of this blog entry.

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.

Comments:

Thanks Alexis - nice introduction.

One thing that occurs to me is that it would be hard to keep both apps in sync if any schema changes occur, but if the business is aware of that it can't be too hard to manage.

N00b question: In order to get this working, do I just need EclipseLink 2.3 JPA jar(s)? Or do I need a specific implementation of EclipseLink 2.3 JPA? Can other JEE servers even support it?

Thanks!

Rob
:)

Posted by Robert Mark Bram on juin 28, 2011 at 09:59 PM CEST #

Hi Alexis

nice one.

Posted by Chuk on juin 29, 2011 at 04:29 AM CEST #

does eclipse link have support for Multi tenancy using multiple DB's.

Posted by Yasser H. on juin 29, 2011 at 08:00 AM CEST #

You should just need EclipseLink 2.3 and you can use this functionality in JavaSE or any container that supports JPA 1.0 or 2.0.

Doug

Posted by Doug on juin 29, 2011 at 11:01 AM CEST #

Yasser,

EclipseLink does have partitioning support for using tables across different schemas/db. On the @Multitenant front we are starting on additional strategies such as TABLE_PER_TENANT.

Doug

Posted by Doug Clarke on juin 29, 2011 at 06:29 PM CEST #

Why are you cloning the application? Isn't multi-tenancy all about using one instance of an application with multiple tentants. I understand that you can have some tenant-specific customization that way. My question is, how does EclipseLink support the scenario where you have one instance of an application with a huge number of tenants? Do you need @Multitenant annotation at all? Would it suffice just to add an extra tenant-id column and include the tenant-id in all queries? And how does @Unique behave in a multi-tenant environment? I would expect that it enforces uniqueness within a single tenant.

Posted by guest on juillet 03, 2011 at 10:12 AM CEST #

This is not a classic Multitenancy app scenario is it? While I understand that it is just a proof of concept, duplicating project might not be the common scenario (think 10 BUs). Also having to rollout updates to the project 10 times might not be ideal. Having tenancy id discriminator being part of the User's Session Context (REALM) might be a more apt way of implementing it.

But the DISCRIMNATOR column annotation on the DB side is perfect.

Posted by guest on juillet 03, 2011 at 11:08 AM CEST #

Yes, this is a simplistic example of multitenancy.
A more realistic one would be to set the tenant-id at injection time (@PersistenceContext).
Mutitenancy is pretty much cross-cutting all the platfoem APIs and I would hope that once Java EE 7 is done, the use-cases are easily usable and are hiding away most or all the details.

Posted by Alexis MP on juillet 03, 2011 at 01:17 PM CEST #

Post a Comment:
Comments are closed for this entry.
About

This blog has moved

Alexis Moussine-Pouchkine's Weblog

GlassFish - Stay Connected

Search

Archives
« avril 2014
lun.mar.mer.jeu.ven.sam.dim.
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today
Blogroll

No bookmarks in folder

News

No bookmarks in folder