Adding multi-tenancy to a Java EE application - jpa

I already have an application using Java EE deployed in Glassfish and I want to add multi-tenancy so that it can support many tenants.
I'm using the following technologies: EJB, JPA (EclipseLink) and JSF
during my research I found three approaches for managing multi-tenant data (persistence layer):
Separate databases
Shared Database, Separate Schemas
Shared Database, Shared Schema
Which approach do you recommand and how can other layers be affected by multi-tenance?

Related

MySQL to ObjectDB Migration

A maven JEE project using JSF, JPA (EclipseLink 2.3) is using MySQL comminity edition as the database. With the size of the database exceeding 20GB, there are database related peformance issues. As a solution, I am going to use ObjectDB.
I am doing to use two persistence units for each database and migrate objects. Will it work? If not, is there any other recommendation? I tired the web to search, but could not find any totorial explaining how to do it ?

Integrating gRPC with Spring Data Jpa for Persistence Layer

I am new to gRPC and I am building a microservice application using Spring Boot. The plan is to use gRPC to create shared entity classes across the microservices. I would like to ask, are the classes generated by gRPC annotated with #Entity annotation and other JPA annotations?
If the above is possible, will I also be able to selectively choose to exclude the JPA annotations? this is because some microservices do not need the entity of other microservices.
Furthermore, what are the best practices for gRPC in Spring Boot? E.g. the libraries available etc.

Using eclipselink JPA and alter persistence context name while deploying on weblogic

While using JPA eclipse link, i would need my application to be deployed per tenant on a weblogic server. But this would not allow me to deploy multiple times with same persistene context name. So is there a way we can specify the persistence context name at runtime/deployment time?

JPA newbie - Container managed persistence using Websphere and OpenJPA

I want to implement Container Managed persistence using Websphere and OpenJPA.
Can anyone provide some insights ?
Is there a way to achieve this without using EJB3 or Spring ?
EJBs and Spring (along with some other Dependency Injection frameworks like Google Guice) implement the Container Managed EntityManager. If you don't want to use the technology that provides the hooks for the container to handle the transactions and entity managers for you, then you would have to roll your own which is the application managed route.

MyBatis integration with JBoss 7.1 web application

Had anybody attempted to use MyBatis as their persistence library for a JBoss 7.1 /Java EE6 application?
I'm wondering what are the best approaches to handling connections, transations, rollbacks etc?
How about CDI support? Looking around online it seems at this time MyBatis only supports two Dependency Injection (JSR-330) frameworks, Google Guice and Spring. I did run into CDI Extensions which may be something look into.
My idea would be to have the container handle all of the above however it may be difficult getting to that point.
Any tips, hints, experiences?
There is a new mybatis-cdi module. It is not released yet, but you can try the snapshot, it is at github: https://github.com/mybatis/cdi
There is no CDI support at all but as you said, if you want DI go Spring or Guice.
With JBoss you have mainly two chances:
- EJB 3
- Spring
If using EJB 3 transactions are handled automatically by them. MyBatis just ignores transactions and lets the container commit/rollback.
When using Spring, MyBatis ties to Spring transactions using the integration module MyBatis-Spring.
I would create my own CDI bean - use #Produces for a factory, and #Inject to get the session.
Here is old iBatis Spring factory, that might be the producer, after some changes:
SqlMapClientFactoryBean