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

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?

Related

I have created a spring boot application

I have added dependency for h2 in memory database in my pom.xml but i have not configured the h2 database properties in my application.properties but still my jpa class are getting created in h2 database, can someone tell how is it possible?
It is due to auto-configuration feature of spring boot
https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/html/using-boot-auto-configuration.html
Spring Boot auto-configuration attempts to automatically configure your Spring application based on the jar dependencies that you have added. For example, if HSQLDB is on your classpath, and you have not manually configured any database connection beans, then Spring Boot auto-configures an in-memory database.
You need to opt-in to auto-configuration by adding the #EnableAutoConfiguration or #SpringBootApplication annotations to one of your #Configuration classes.

Adding multi-tenancy to a Java EE application

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?

NetBeans: create Entity from Database

I need to reverse engineer my database tables into Entity to run a Java EE project on JBoss AS 7. So I've added into the Services the JBoss application server and added as well as resources a MySQL datasource.
However, when I try to run the wizard Create Entity from Database I can see as only option the default ExampleDS Database. There is no other option to create a new DataSource or use the MySQL DataSource that I've installed on JBoss.
I wonder if it's a NetBeans bug, or I'm missing something. I'm using NetBeans 8.0.1 version.
I think it's an issue with the plugin that you are using for connecting to the application server. I remember I had this issue when I first tried to generate Entity classes from a Database using a Datasource on WildFly. Are you sure that the target application server is JBoss AS 7 and not WildFly ?
If so, try to connect the application to a JBoss AS 7 /EAP 6 instead and see if it works.
Hope it helps
Edit: I've included a JBoss NetBeans tutorial which shows the steps for reverse engineering database tables into Entity classes (and then JSF pages).

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.

Access EJB from JAX-RS

While Developing a Java EE Web app, I would like to know simple ways to access an stateless EJB object through Rest.
This project needs no Dynamic Web from Java, as Client side is fully javascript deployed, so communication is done only with Ajax calls.
As I've read one way would be to create 2 EJB one for functionality other to represent Web Service.
Is there a way to avoid the Web Service part? (avoid completely the WAR) Maybe with DI?
Java EE 6, EJB 3.1, Eclipse desired. I also believe the right application server would be Glassfish instead of Jboss, due to it's compatibility with EJB 3.0
No interesting in using JAX-WS
With EJB 3.1 you can actually publish a session bean as a JAX-RS web service, if you package your (properly annotated) session bean inside a WAR.
So, the simplest solution I can think of would be to create a WAR (a dynamic web app if you're using Eclipse) and create a JAX-RS annotated stateless session bean inside the web app. You don't need any EJB projects at all.
Not really. In Java EE 6 you can directly publish a Session Bean as a JAX-WS web service, but not as a JAX-RS web service. You're pretty much stuck with creating a WAR that hosts that JAX-RS services that front the EJBs themselves.