Sneak peak at Java EE 7 - Multitenant Examples with EclipseLink


News: Sneak peak at Java EE 7 - Multitenant Examples with EclipseLink

  1. The Aquarium is a great source of inspiration and most recent information about Java EE progress across all relevant specifications and reference implementations. They picked up a presentation by Oracle's Shaun Smith (blog/twitter) about the status and future of EclipseLink as an open source project. He covers all the new features which are going to be in EclipseLink 2.4 which will be availabke along with the June Eclipse Juno Release. In detail these are REST, NoSQL and Multitenancy. (details refer to the complete slide-deck (PDF) from the marsjug event.)

    I like to see that EclipseLink still is the center of innovation in Java persistence and they are trying hard to adopt latest buzz timely. Working for a more conservative industry in general the main new feature I am looking for is multitenancy. What you can guess from the slides is, that something in this field should already be working with latest EclipseLink 2.3.0.

    What is Multitenancy going to look like?
    Let's start looking at what Oracle's Linda DeMichiel announced at last years JavaOne (compare blog-post) and also let's look at what the early draft (PDF) of the JPA 2.1 specification has to offer. The easier part is the early draft. Not a single line mentions "Multitenan[t|cy]" in any context. So, this is obviously still a big to do for further iterations. A bit more could be found in the JavaOne Strategy Keynote (Slides 41,42) and the JavaOne Technical Keynote (PDF) (Slide 25). The general Java EE 7 approach will be to have support for separate isolated instances of the same app for different tenants. The mapping should be done by the container and be available to apps in some way. This is all very vague until today and the only concrete code examples available from the slides refer to some obvious JPA related examples using two annotations @Multitenant and @TenantDiscriminatorColumn. Hmm. Doesn't this look familiar to you? 

    What is possible today?
    It does! EclipseLink (as of 2.3.0 - Indigo) supports shared multitenant tables using tenant discriminator column(s), allowing an application to be re-used for multiple tenants and have all their data co-located. All tenants share the same schema without being aware of one another and can use non-multitenant entity types as per usual. But be aware of the fact, that this is only one possible approach to multitenancy for data. This is commonly referred to as "dedicated database" because all tenant's data go into one single db! The basic principles for the following are:
    - application instances handle multiple tenants
    - caching has to be isolated for every tenant by JPA
    You can look at all the details on a dedicated EclipseLink wiki page. Want to give it a test drive? let's start. Prerequisites as usual (NetBeans, GlassFish, MySQL, compare older posts if you need more help.). Make sure to have the right EclipseLink dependencies (at least 2.3.0)! Create a new entity via the wizard, setup your datasource and persistence.xml and call it e.g. Customer.


    Read the rest of the article at the following URL:

    Java Code Geeks: Sneak peak at Java EE 7 - Multitenant Examples with EclipseLink

  2. Nothing new. This has been available for some time with DataNucleus JPA and also Hibernate too IIRC