Want to dive even deeper?

Take the course Designing Moodle Themes by Susan Smith Nash and become an expert!
Designing Moodle Themes
by Susan Smith Nash

Check it out!
You're watching a preview of this video, click the button on the left to puchase the full version from Atomikos ExtremeTransactions Certification.

JPA Multi-Tenancy & Extensibility

One of the major themes of Java EE 7 and JPA 2.1 is multi-tenancy and EclipseLink, the JPA 2.1 reference implementation, has blazed the trail by shipping support for both multi-tenancy and tenant specific extensions in the Eclipse Indigo release. EclipseLink multi-tenancy enables the use of a single persistence unit by multiple tenants while keeping their data isolated and secure.

Published on
  • 3.273
  • 50
  • 0
  • 2
  • 0
  • Multi-Tenancy & Extensibility: Blazing the Trail to JPA 2.1 in EclipseLink Shaun Smith Eclipse Commiter/Oracle TopLink shaun.smith@oracle.com @shaunMsmith
  • About Me · From Toronto, Canada · Product Manager at Oracle for TopLink · Object-Relational Mapping since '96! · Committer on various Eclipse projects including EclipseLink 2
  • Multitenancy Wikipedia http://en.wikipedia.org/wiki/Multitenancy · Multitenancy refers to a principle in software architecture where a single instance of the software runs on a server, serving multiple client organizations (tenants). · Multitenancy is contrasted with a multi-instance architecture where separate software instances (or hardware systems) are set up for different client organizations. 3
  • Application Dev and the Cloud · Today ­Single Tenant or non-Tenant Applications ­Dedicated application instance and database · Future ­Support multiple tenants ­Support extensibility (custom fields per tenant) ­Support various deployment architectures · Dedicated or shared application instances · Dedicated or shared databases 4
  • So Many Clouds · Infrastructure - IaaS ­E.g. Amazon Web Services · Platform ­ PaaS ­E.g. Oracle Public Cloud, Cloud Bees, Google App Engine · Software ­ SaaS ­E.g. SalesForce.com, Google Mail 5
  • Java Persistence: The Problem Space Customer id: int name: String creditRating: int Java JAXB/SDO <customer id="..."> <name>...</name> ... </contact-info> </customer> XML JPA DBWS CUST ID NAME C_RATING Relational JPA: Java Persistence API JAXB: Java Architecture for XML Binding SDO: Service Data Objects 6
  • EclipseLink Project · Object-Relational: Java Persistence API (JPA) ­JPA 1.0 part of EJB 3.0 standard (JSR 220) ­JPA 2.0 standardized in JSR 317 ­EclipseLink is JPA 2.0 Reference Implementation · Object-XML: Java Architecture for XML Binding (JAXB) ­JAXB 2.2 Certified Implementation · Object-XML: Service Data Objects ­SDO 2.1.1 standardized in JSR 235 ­EclipseLink is SDO 2.1.1 Reference Implementation
  • EclipseLink Project Java SE Java EE OSGi Spring ADF JPA MOXy DBWS Databases XML Data Legacy Systems 8
  • Multitenant Topologies Application Dedicated T1 T2 T3 Shared T1 T2 T3 Dedicated Database 1 2 T2 3 T3 1 2 3 T1 T1 T2 T3 Shared 1 2 3 1 2 3 Note: Single application deployed to support various MT architectures 9
  • Multitenant: Dedicated Application Dedicated DB · Dedicated application Instance ­Application instance per tenant · unique container or application class-loader 1 2 3 T1 T2 T3 ­Caching supported · Dedicated database ­Unique tables (tablespace/schema/db) per tenant ­Tenant specific data source required 10
  • Multitenant: Shared App Dedicated DB · Shared Application Instance ­Application instances handle multiple tenants ­Caching must isolate by tenant T1 T2 T3 1 2 3 · Dedicated Database ­Common data source · Unique schema/tablespace per tenant · Common schema with table per tenant · Proxy Authentication ­Data source per tenant 11
  • Shared Database · @Multitenant ­Application's persistence layer manages access ­Row data includes tenant identifier values ­Queries augmented to limit results based on current tenant ­Database vendor independent T1 T2 T3 1 2 3 T1 T2 T3 1 2 3 · @Multitenant(VPD) ­Row data includes tenant identifier values ­Database provides client limited view of database tables · Shared solution for all database clients · Native queries (SQL) supported 12
  • Multitenant Entity Strategies · GOAL: support storage of entities from multiple tenants in a single shared schema · @Multitenant Strategies ­@Multitenant(SINGLE_TABLE) - default ­@Multitenant(VPD) · SINGLE_TABLE + includeCriteria=false · SET_IDENTIFIER(property) & CLEAR_IDENTIFIER · DDL Gen of predicate function and ADD_POLICY ­@Multitenant(TABLE_PER_TENANT) 13
  • In the beginning... · Application dedicated for single tenant · All rows available to all queries @Entity public class Player { PLAYER ID 1 2 VERSION 1 3 F_NAME John Jane L_NAME Doe Doe LEAGUE HTHL OSL 14
  • DEMO--JPA No Tenancy
  • Multitenant: SINGLE_TABLE · Simple configuration: Annotation or XML · Flexible tenant identifier support · EclipseLink augments generated SQL @Entity @Multitenant @TenantDiscriminatorColumn(name="league-id", columnName="LEAGUE") public class Player { PLAYER ID 1 2 VERSION 1 3 F_NAME John Jane L_NAME Doe Doe LEAGUE HTHL OSL 16
  • DEMO--SINGLE TABLE Multitenancy
  • Multitenant using Oracle VPD · Leverage the Oracle Database @Entity @Multitenant(VPD) @TenantDiscriminatorColumn(name="league-id", columnName="LEAGUE") public class Player { PLAYER ID 1 2 VERSION 1 3 F_NAME John Jane L_NAME Doe Doe LEAGUE HTHL OSL 18
  • Multitenant: TENANT_PER_TABLE · Planned Feature @Entity @Multitenant(TABLE_PER_TENANT) public class Player { HTHL.PLAYER ID 1 VERSION 1 F_NAME John L_NAME Doe OSL.PLAYER ID 2 VERSION 3 F_NAME Jane L_NAME Doe 19
  • Caching & Multitenancy · EntityManagerFactory/Tenant--Shared Cache Tenant 1 / Thread 1 EntityManager Persistence Context Tenant 1 / Thread 2 EntityManager Tenant 2 Thread EntityManager Persistence Context ... Persistence Context Tenant 1-EntityManagerFactory Shared Cache Tenant 2-EntityManagerFactory Shared Cache 20
  • Caching & Multitenancy · EntityManager/Tenant--Shared Cache Disabled Tenant 1 / Thread 1 EntityManager Persistence Context Tenant 1 / Thread N EntityManager Tenant 2 / Thread 1 EntityManager Persistence Context ... Persistence Context Tenant 1-EntityManagerFactory 21
  • Caching & Multitenancy · EntityManagerFactory/Tenant--Shared Cache Tenant 1 / Thread 1 EntityManager Persistence Context Tenant 1 / Thread 2 EntityManager Tenant 2 Thread EntityManager Persistence Context ... Persistence Context Tenant 1-EntityManagerFactory Shared Cache Tenant 2-EntityManagerFactory Shared Cache 20
  • MySports Demo · Introduced in EclipseLink Indigo (2.3) · Features ­@Multitenant · EMF per tenant (shared cache enabled) ­@VirtualAccessMethods (Extensions per Tenant) ­External Metadata Sources ­JSF, EJB, JPA ­Admin: JSF + JAX-RS + JPA · Wiki ­http://wiki.eclipse.org/EclipseLink/Examples/MySports 22
  • MySports Demo Model 23
  • Multi-Tenancy at Runtime App Session Scope league-id=1 App Services JPA EMF EntityManager EntityMar <<per app txn>> <<per app txn>> <<app singleton>> SELECT * FROM MYS_PLAYER WHERE L_NAME = `Doe' AND LEAGUE = 1
  • Domain Model Extensions
  • Domain Model Extensions · Storage and querying of extended properties ­Application developer enables extensions in entity ­Schema created with extension columns/table(s) ­Application Admin stores extension definitions ­Application instances made aware of extension definitions ­Application users make use of extensions Employee id firstName lastName extensions * name value 28 Map<String, Object>
  • Flex Extensions @VirtualAccessMethods public class Player{ ... @Transient private Map<String, Object> attributes; public <T> T get(String attributeName) { return (T) this.attributes.get(attributeName); } public Object set(String attributeName, Object value) { return this.attributes.put(attributeName, value); } PLAYER ID 1 2 F_NAME John Jane L_NAME Doe Smith FLEX_1 `R' `NONE' FLEX_2 '22'
  • Virtual Access Mappings <entity class="example.mysports.model.Player"> <attributes> <basic name="penaltyMinutes" access="VIRTUAL" attribute-type="java.lang.Integer"> <column name="flex_1"/> </basic> <basic name="position" access="VIRTUAL" attribute-type="java.lang.String"> <column name="flex_2"/> </basic> </attributes> </entity>
  • MySports Architecture Users Admin Create / Update / Remove Extension Definitions JSF EJB/JPA EclipseLink deploy REST -> <- XML Admin App JSF/JAX-RS/EJB/JPA EclipseLink Metadata Repository
  • EclipseLink Roadmap · Implement JPA 2.1 Multitenancy specification · Broaden Multitenancy support for other data storage architectures, e.g. Table per Tenant · Broaden Entity Extensions support for alternate metadata and extended data database architectures · Other EclipseLink Initiatives ­JSON Binding--Java/JSON marshall/unmarshall ­JPA-RS: Expose JPA data services over REST (XML or JSON) ­Resource Mapping--Declarative REST Resource Model ­EclipseLink NoSQL--JPA for NoSQL Databases 33 ­Dynamic Persistence--100% metadata driven
  • Summary · Starting thinking about SaaS/PaaS and your applications · Java EE 7 targeting Cloud deployment · JPA 2.1 to include multitenancy support · Download EclipseLink Indigo (2.3.1) ­ http://wiki.eclipse.org/EclipseLink/Examples/MySports ­ http://wiki.eclipse.org/EclipseLink/Examples/JPA/Multitenan t/Tutorial · Provide Feedback, Get Involved! ­ http://eclipse.org/eclipselink for user forums and lists

Comments

Be the first one to add a comment

Thumbnail for: Findings Revealed: 2015 State of the Software Supply Chain

Findings Revealed: 2015 State of the Software Supply Chain

WaiMan Yau

free
Thumbnail for: Web Application Security Reloaded for the HTML5 era

Web Application Security Reloaded for the HTML5 era

Carlo Bonamico

free
Thumbnail for: Gimme Caching - The Distributed JCache(JSR107) Way

Gimme Caching - The Distributed JCache(JSR107) Way

David Brimley

free
Thumbnail for: How to lower the power consumption of your app, without affecting performance

How to lower the power consumption of your app, without affecting performance

Rick Schwartz

free
Thumbnail for: Never mind the bollocks: here's the Linux containers

Never mind the bollocks: here's the Linux containers

Patrick Chanezon

free
Thumbnail for: NOW TV and Linear Streaming: The unpredictable scalability challenge

NOW TV and Linear Streaming: The unpredictable scalability challenge

Tom Maule

free
Thumbnail for: The end of server management : hosting has to become a commodity

The end of server management : hosting has to become a commodity

Quentin ADAM

free
Thumbnail for: The Future of Personal Robotics

The Future of Personal Robotics

Nicolas Rigaud

free
Thumbnail for: Performance Tuning, Top 10 Your Doing it Wrong!

Performance Tuning, Top 10 Your Doing it Wrong!

Kirk Pepperdine

free
Thumbnail for: Let’s Get to the Rapids: Java 8 Stream Perfomance

Let’s Get to the Rapids: Java 8 Stream Perfomance

Maurice Naftalin

free
Thumbnail for: Pushing The Limits With Java Enterprise Cloud Development

Pushing The Limits With Java Enterprise Cloud Development

Simon Ritter

free
Thumbnail for: JCP, Adopt-a-JSR & You

JCP, Adopt-a-JSR & You

Heather VanCura

free
Thumbnail for: 3 Keys to Rapid Deployment Success

3 Keys to Rapid Deployment Success

Sven Erik Knop

free
Thumbnail for: Bringing IBM Watson to the Cloud

Bringing IBM Watson to the Cloud

Dale Lane

free
Thumbnail for: The Smartwatch Revolution begins: Developing for Android Wear

The Smartwatch Revolution begins: Developing for Android Wear

Pratik Patel

free
Thumbnail for: The Google Cloud Plaform - Beyond simple use cases

The Google Cloud Plaform - Beyond simple use cases

David Gageot

free
Thumbnail for: The Cloud, an Arduino, an Application, Server, and me - Adventures In and Out of the Cloud

The Cloud, an Arduino, an Application, Server, and me - Adventures In and Out of the Cloud

Holly Cummins

free
Thumbnail for: TestOps - Chasing the White Whale

TestOps - Chasing the White Whale

Ioana Serban

free
Thumbnail for: Experimenting with ServiceWorker

Experimenting with ServiceWorker

Sandro Paganotti

free
Thumbnail for: Accessibility and how to get the most from your screenreader

Accessibility and how to get the most from your screenreader

Edd Sowden

free
Thumbnail for: What Were You Doing In 1995? A 20 Year Retrospective of Java

What Were You Doing In 1995? A 20 Year Retrospective of Java

Simon Ritter , Steve Elliott

free
Thumbnail for: SQL’s back: querying document databases the old fashioned way

SQL’s back: querying document databases the old fashioned way

Matthew Revell

free
Thumbnail for: Decoding the air around you with Java and $7 hardware

Decoding the air around you with Java and $7 hardware

Bert Jan Schrijver

free
Thumbnail for: "Catch me if you can" - Java on wearables

"Catch me if you can" - Java on wearables

Gerrit Grunwald

free
Thumbnail for: Miniboxing: Fast Generics for Primitive Types

Miniboxing: Fast Generics for Primitive Types

Vlad Ureche

free
Thumbnail for: goto java;

goto java;

Martin Skarsaune

free
Thumbnail for: Java 8 in Anger

Java 8 in Anger

Trisha Gee

free
Thumbnail for: Not my department?! How our privacy is broken and what you can do about it.

Not my department?! How our privacy is broken and what you can do about it.

Anna Biselli

free
Thumbnail for: The Hidden Gems of PDF

The Hidden Gems of PDF

Michaël Demey

free
Thumbnail for: Design Patterns in the 21st Century

Design Patterns in the 21st Century

Samir Talwar

free
Thumbnail for: Keynote: The Extraordinary Team of Developers

Keynote: The Extraordinary Team of Developers

Trisha Gee , Daniel Bryant

free
Thumbnail for: Java Generics: Past, Present and Future

Java Generics: Past, Present and Future

Richard Warburton , Raoul-Gabriel Urma

free
Thumbnail for: Building securely with agile

Building securely with agile

Michael Brunton-spall

free
Thumbnail for: STOP BREAKING MY STUFF

STOP BREAKING MY STUFF

Katharine Fitzpatrick

free
Thumbnail for: All Change! How the new economics of Cloud will make you think differently about Java

All Change! How the new economics of Cloud will make you think differently about Java

Steve Poole

free
Thumbnail for: Powering real-time web apps with Hazelcast

Powering real-time web apps with Hazelcast

Andrejs Jermakovics

free
Thumbnail for: What is your build telling you about your application structure?

What is your build telling you about your application structure?

Abraham Marin-Perez

free
Thumbnail for: Practical Challenges of moving from CI to CD using Maven

Practical Challenges of moving from CI to CD using Maven

Jatin Bhadra

free
Thumbnail for: Destination: Cloud. Deploying Applications To The Cloud With Docker

Destination: Cloud. Deploying Applications To The Cloud With Docker

Ryan Baxter

free
Thumbnail for: Finally, Security API JSR 375

Finally, Security API JSR 375

Alex Kosowski

free
Thumbnail for: Level up your Android Build

Level up your Android Build

Volker Leck

free
Thumbnail for: Practical Continuous Deployment

Practical Continuous Deployment

Steve Smith

free
Thumbnail for: The Seven Deadly Sins of Microservices

The Seven Deadly Sins of Microservices

Daniel Bryant

free
Thumbnail for: Making Events for Local Dev Communities

Making Events for Local Dev Communities

Celestino Bellone , Federico Yankelevich

free
Thumbnail for: Nuts and Bolts of WebSocket

Nuts and Bolts of WebSocket

Arun Gupta

free
Thumbnail for: Developing iOS applications with Java and Eclipse

Developing iOS applications with Java and Eclipse

Grant Ronald

free
Thumbnail for: Welcome Keynote

Welcome Keynote

Mark Hazell

free
Thumbnail for: Refactor your Java EE application using Microservices and Containers

Refactor your Java EE application using Microservices and Containers

Arun Gupta

free
Thumbnail for: Java EE 8, a snapshot overview

Java EE 8, a snapshot overview

David Delabassee

free
Thumbnail for: The Dark arts of building your own framework

The Dark arts of building your own framework

Andrey Glaschenko , Konstantin Krivopustov

free
Thumbnail for: Programming at any Scale

Programming at any Scale

Andrew Harmel-Law

free
Thumbnail for: Java is dead, long live Ceylon, Kotlin,…

Java is dead, long live Ceylon, Kotlin,…

Russel Winder

free
Thumbnail for: Android Testing: A New Hope

Android Testing: A New Hope

Zan Markan , Nicholas Jackson

free
Thumbnail for: Java EE changes design pattern implementation

Java EE changes design pattern implementation

Alex Theedom

free
Thumbnail for: Building Cloud Powered Android Apps with Azure

Building Cloud Powered Android Apps with Azure

Chris Risner

free
Thumbnail for: From 0 to 60 million users: Scaling for speed and high availability

From 0 to 60 million users: Scaling for speed and high availability

Aviran Mordo

free
Thumbnail for: HTTP/2 comes to Java. What Servlet 4.0 means to You

HTTP/2 comes to Java. What Servlet 4.0 means to You

David Delabassee

free
Thumbnail for: 50 minutes to develop a full Java EE application with Forge? Is that all?

50 minutes to develop a full Java EE application with Forge? Is that all?

Antonio Goncalves

free
Thumbnail for: How to Rock your Web Apps with Spring and Vaadin

How to Rock your Web Apps with Spring and Vaadin

Sami Ekblad

free
Thumbnail for: In-Memory Computing - Distributed Systems

In-Memory Computing - Distributed Systems

Christoph Engelbert

free
Thumbnail for: Comparing different concurrency models on the JVM

Comparing different concurrency models on the JVM

Mario Fusco

free
Thumbnail for: 5 reasons why developers should pay attention to robotics

5 reasons why developers should pay attention to robotics

Nicolas Rigaud

free
Thumbnail for: Ceylon from here to infinity: the big picture and what's coming

Ceylon from here to infinity: the big picture and what's coming

Stephane Epardaud

free
Thumbnail for: Is your profiler speaking the same language as you?

Is your profiler speaking the same language as you?

Simon Maple

free
Thumbnail for: Java 9: Make Way for Modules!

Java 9: Make Way for Modules!

Mark Reinhold

free
Thumbnail for: Akka Streams with Scala and Java

Akka Streams with Scala and Java

Jamie Allen

free
Thumbnail for: The 10 Golden Rules of Mobile UX

The 10 Golden Rules of Mobile UX

Emilia Ciardi

free
Thumbnail for: Ludicrously Fast Builds with Buck

Ludicrously Fast Builds with Buck

Simon Stewart

free
Thumbnail for: Making Enterprise Java Architecture Sustainable

Making Enterprise Java Architecture Sustainable

Markus Eisele

free
Thumbnail for: Combining R with Java for Data Analysis

Combining R with Java for Data Analysis

Ryan Cuprak , Elsa Cuprak

free
Thumbnail for: Diversity Rules!

Diversity Rules!

Amali de Alwis

free
Thumbnail for: Flyway - Database Migration made easy

Flyway - Database Migration made easy

Axel Fontaine

free
Thumbnail for: Microservices Made Easy with Spring Cloud and Netflix OSS

Microservices Made Easy with Spring Cloud and Netflix OSS

David Syer

free
Thumbnail for: CDI 2.0: what is in the work?

CDI 2.0: what is in the work?

Antoine Sabot-Durand , José Paumard

free
Thumbnail for: WildFly 9

WildFly 9

Kabir Khan

free
Thumbnail for: Functional patterns for scala beginners

Functional patterns for scala beginners

Clément Delafargue

free
Thumbnail for: Devoxx4Kids

Devoxx4Kids

Dan Hardiker

free
Thumbnail for: Let’s Get to the Rapids: Java 8 Stream Perfomance

Let’s Get to the Rapids: Java 8 Stream Perfomance

Maurice Naftalin

free
Thumbnail for: Level Up your Dev Skills with Static Analysis

Level Up your Dev Skills with Static Analysis

David Lindsay

free
Thumbnail for: From Requirements to Deployment: Implementing a Microservice in Java using BDD and TDD

From Requirements to Deployment: Implementing a Microservice in Java using BDD and TDD

John Ferguson Smart

free
Thumbnail for: Predicting the Future with Machine Learning

Predicting the Future with Machine Learning

Amy Nicholson

free
Thumbnail for: Software Architecture as Code

Software Architecture as Code

Simon Brown

free
Thumbnail for: Top 10 Real-life WebSocket Use Cases and Experiences

Top 10 Real-life WebSocket Use Cases and Experiences

Richard Cullen

free
Thumbnail for: The First IoT JSR: Units of Measurement

The First IoT JSR: Units of Measurement

Leonardo Lima , Chris Senior

free
Thumbnail for: One Framework, No Dependencies: Using Frameworks to Avoid Common Pitfalls of App Development

One Framework, No Dependencies: Using Frameworks to Avoid Common Pitfalls of App Development

Lee Boonstra

free
Thumbnail for: Building the UKs biggest IoT network

Building the UKs biggest IoT network

Romanas Sonkinas

free
Thumbnail for: Never Mind the Devoxx

Never Mind the Devoxx

David Blevins

free
Thumbnail for: Five Ways to Not Suck at Being a Java Freelancer

Five Ways to Not Suck at Being a Java Freelancer

Roberto Cortez

free
Thumbnail for: Java EE Game Changers

Java EE Game Changers

David Blevins

free
Thumbnail for: Express yourself with Java 8

Express yourself with Java 8

Benjamin Weber

free