Spring ORM & Hibernate
- Spring ORM - Create Project
- Spring ORM - Maven Hibernate
- Spring ORM - Persistence Hibernate
- Spring ORM - Update Project
- Spring ORM - Run & Test Hibernate
Spring ORM & EclipseLink
- Spring ORM - Maven EclipseLink
- Spring ORM - Persistence EclipseLink
- Spring ORM - Update Project EclipseLink
- Spring ORM - Run & Test EclipseLink
Spring ORM & Useful Resources
Spring ORM - Persistence EclipseLink
persistence.xml defines the various aspects related to eclipselink like following.
Persistence Unit − A persistence unit containing all the details. It's name is used to get reference in spring context.
provider − org.eclipse.persistence.jpa.PersistenceProvider class will be used as provider.
Database url and credentials − In properties section, we pass the database related values.
class − to register the class to be persisted.
eclipselink.ddl-generation − to allow eclipselink to create tables.
Create persistence.xml in src -> main > resources > META-INF folder.
persistence.xml
<persistence 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_1.xsd" version="2.1">
<persistence-unit name="EclipseLink_JPA">
<description> Spring EclipseLink JPA Configuration Example</description>
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.tutorialspoint.jpa.entity.Employee</class>
<properties>
<property name="jakarta.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver" />
<property name="jakarta.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/tutorialspoint" />
<property name="jakarta.persistence.jdbc.user" value="guest" />
<property name="jakarta.persistence.jdbc.password" value="guest123" />
<property name="eclipselink.logging.level" value="FINE"/>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
Advertisements