I'm trying to use JPA, Hibernate with OpenLiberty to develop a JakartaEE Application.
I followed this document: https://openliberty.io/guides/jpa-intro.html#configuring-jpa
In my case, I'm hoping to use either jpaContainer-2.2 or jpa-2.2.
Some of the code snippets are as below,
persistence.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence version="2.2"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="jpaunit" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>jdbc/recruittimesdb</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.temp.use_jdbc_metadata_defaults" value="true" />
</properties>
</persistence-unit>
</persistence>
server.xml
<dataSource id="hibernatemysqldb"
jndiName="jdbc/recruittimesdb">
<jdbcDriver libraryRef="MySQLLib" />
<properties databaseName="recruit_times_db"
serverName="localhost" password="admin1234" user="root"
serverTimezone="UTC" portNumber="3306" />
</dataSource>
<library id="MySQLLib">
<file
name="C:/Users/harsha/Documents/mysql-connector-java-8.0.19.jar" />
</library>
<library id="hibernate">
<fileset dir="${config.dir}/hibernate/"
includes="*.jar" />
</library>
I'm still not able to integrate Hibernate successfully. It would be great to see a working example.
UPDATE:
When the server starts up, I get this error.
[INFO] [ERROR ] CWWJP0015E: An error occurred in the org.hibernate.jpa.HibernatePersistenceProvider persistence provider when it attempted to create the container entity manager factory for the jpaunit
persistence unit. The following error occurred: [PersistenceUnit: jpaunit] Unable to build Hibernate SessionFactory