Value of provider in Persistence.xml - jpa

What is the value to be set in provider XML element of persistence.xml if the Oracle database is used? Which jars need to included to write a simple JPA application?.
I have currently included only ejb3-persistence.jar.
When the application is run, below error is seen,
javax.persistence.PersistenceException: No Persistence provider for EntityManage

Decide which JPA implementation you're going to use :- some to choose from DataNucleus, OpenJPA, Hibernate, EclipseLink all of which support persistence to Oracle RDBMS, and there are likely others. Each has a "provider" class name, so you use that in persistence.xml

Related

Does Spring Data JPA internally use Hibernate & why my app is working if I am not giving dialect property?

I just started learning Spring Data JPA, I connected to mysql in localhost and able to save a record but I am unable to understand why it is working if I am not giving dialect property in properties file and is hibernate a default implementation of spring data instead of ibatis or Eclispe link, because in my pom.xml I just added the dependency of spring-data-jpa and never mentioned what kind of JPA implementation I want to use.
application.properties
spring.jpa.hibernate.ddl-auto=create
spring.jpa.properties.hibernate.
spring.datasource.url=jdbc:mysql://localhost:3306/initsoftware
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=ppppppp
spring.datasource.password=xxxxxxx
logging.level.root=DEBUG
spring.jpa.show-sql=true
Since you have an application.properties I assume you are using Spring Boot and not just Spring Data JPA.
In order to use JPA with Spring Boot you would typically add spring-boot-starter-data-jpa to your dependencies. This indeed comes with Hibernate out of the box as you can see when you inspect the dependencies.
Spring Data JPA itself doesn't come with a JPA implementation. You have to add that.
iBatis is not a JPA implementation.
If the assumption above doesn't match your scenario you can use the maven dependency plugin to inspect your (transient) dependencies. The following is a good starting point.
mvn dependency:tree -Dverbose
If you use a different build tool, it probably has a similar feature.

Spring boot with shared JavaEE entities jar

I got a problem where I'm not able to find a solution.
We got a shared library with all entities which are setup to use with JavaEE 6 entities (Websphere). So mapping is based on the JavaEE 6 jpa annotations.
unfortunately this doesn't work out of the box with Spring Boot. Because not all annotations combinations are supported.
e.g.:
Caused by: org.hibernate.AnnotationException: #Column(s) not allowed on a #OneToOne property:
Used Database is db2. The connection works fine. Only the share entity model does not work out the box.
I'm looking now to use a spring boot application that uses openjpa with a db2 database and a persistence.xml with an external jar file. Someone got any experience with this?

OSGI JPA Persistence - Handling multiple model bundles persistence.xml

In my project i have a persistence bundle which will perform the create/update/delete operations and multiple model bundles.
persistence bundle:
PersistenceService.java - Exposed as a service.
PersistenceServiceImpl.java
persistence.xml - contains:
a: jta-data-source details
b: dialect properties.
Now i have multiple model bundles where i have used annotations for declaring entities.
My query is, how i can specify the different model bundles details in the above mentioned persistence bundle's persistence.xml. so that the i can maintain a single persistence.xml file and "PersistenceUnitInfo" will not be repeated.
is it possible? or is there any other best practices?

modifying the persistence.xml at runtime

I've searched for an answer to my problem on google and various forums, but couldn't find a solution. I'm currently trying to modify the persistence.xml at runtime by adding a persistence unit to the file.
The solutions for this question were always "pass a Map of properties when creating an EntityManagerFactory (or EntityManager)" but i need to save the new persistence unit in the persistence.xml, because the application is going to have 100 or even more persistence unit's, one for each tenant that will register to the service, each tenant will have his own database. I'm currently using EclipseLink 2.3.3 as my JPA implementation, EJB 3.1 and jboss 7.1.1.Final as my application server.
Is it possible to modify the persistence.xml at runtime (on the fly)?
The persistence.xml is a deployed artifact, so would be difficult to modify at runtime. I think passing a properties map to createEntityManagerFactory is your best solution, what issue are you having with this?
You may also want to try using the PersistenceProvider API, createContainerEntityManagerFactory() that takes a PersistenceUnitInfo.
Also, consider using EclipseLink's multi-tenant support,
http://www.eclipse.org/eclipselink/documentation/2.5/solutions/multitenancy.htm

How can I transform Entity-Based diagram to a JPA java code

I have class diagram created with "Sparx Enterprise Architect v8.0" and i need to generate JPA-based classes with annotations that reflect relations to use it in the code.
The problem is that i can convert it to EJB but not JPA which is required for my task.
I don't know this product, however they claim that it:
supports modeling of database schema and automatic generation of DDL scripts for eleven DBMS targets out-of-the-box
Once you have the database schema I believe there are various tools that can reverse engineer it and generate JPA entities. Few random hits in Google:
Generating Persistence Mappings from Database Schema
Creating JPA entity beans from database tables
Object-Relational Mappings: Generating JPA Entities
Have a look at the JPA Modeler for Netbeans, will be best fit for your requirement :
generate the database schema and DAO classes from class diagram
You can find the demo here : JPA Modeler Demo - Youtube
If you export your model to ecore format, then you can use Texo to generate JPA annotated POJO for your model.
G9 plugin from Marketplace in Spring Tool Suit did job.
Install Plugin G9
Select Project (JAVA)
Import "Import Database Model"
Select JDBC Driver (In my case mysql)
Maintain JDBC Connection
New
Provide Driver Name, Add Jar, Port, Driver Class and connection url along with schema (jdbc:mysql://localhost:3306/{schema_name})
Close JDBC Connection Box
Port, DB Name, User Name and PWD
Fetch
Reference URL https://www.esito.no/produkter/dbimport/