- Spring ORM 教程
- Spring ORM - 主页
- Spring ORM - 概述
- Spring ORM - 环境设置
- Spring ORM 和 Hibernate
- Spring ORM - 创建项目
- Spring ORM - Maven Hibernate
- Spring ORM - 持久化 Hibernate
- Spring ORM - 更新项目
- Spring ORM - 运行和测试 Hibernate
- Spring ORM 和 EclipseLink
- Spring ORM - Maven EclipseLink
- Spring ORM - 持久性 EclipseLink
- Spring ORM - 更新项目 EclipseLink
- Spring ORM - 运行和测试 EclipseLink
- Spring ORM 有用资源
- Spring ORM - 快速指南
- Spring ORM - 有用的资源
- Spring ORM - 讨论
Spring ORM - 持久性 EclipseLink
persistence.xml 定义了与 eclipselink 相关的各个方面,如下所示。
持久性单元- 包含所有详细信息的持久性单元。它的名称用于在 spring 上下文中获取引用。
提供者- org.eclipse.persistence.jpa.PersistenceProvider 类将用作提供者。
数据库 url 和凭据- 在属性部分中,我们传递数据库相关值。
class - 注册要持久化的类。
eclipselink.ddl- Generation - 允许 eclipselink 创建表。
在 src -> main > resources > META-INF 文件夹中创建 persistence.xml。
持久性.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="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/tutorialspoint?useSSL=false" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="root@123" />
<property name="eclipselink.logging.level" value="FINE"/>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>