- 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
现在在 eclipse 中,在 MainApp.java 上单击右键,选择 Run As 上下文菜单,然后选择 Java Application。检查 eclipse 中的控制台日志。你可以看到以下日志 -
... Sep 28, 2021 8:56:13 AM org.springframework.orm.jpa.LocalEntityManagerFactoryBean createNativeEntityManagerFactory INFO: Building JPA EntityManagerFactory for persistence unit 'EclipseLink_JPA' [EL Config]: metadata: 2021-09-28 08:56:13.763--ServerSession(712627377)--Thread(Thread[main,5,main])--The access type for the persistent class [class com.tutorialspoint.jpa.entity.Employee] is set to [FIELD]. [EL Config]: metadata: 2021-09-28 08:56:13.787--ServerSession(712627377)--Thread(Thread[main,5,main])--The alias name for the entity class [class com.tutorialspoint.jpa.entity.Employee] is being defaulted to: Employee. [EL Config]: metadata: 2021-09-28 08:56:13.802--ServerSession(712627377)--Thread(Thread[main,5,main])--The column name for element [id] is being defaulted to: ID. Sep 28, 2021 8:56:13 AM org.springframework.orm.jpa.LocalEntityManagerFactoryBean buildNativeEntityManagerFactory INFO: Initialized JPA EntityManagerFactory for persistence unit 'EclipseLink_JPA' [EL Info]: 2021-09-28 08:56:14.102--ServerSession(712627377)--Thread(Thread[main,5,main])--EclipseLink, version: Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5 [EL Fine]: connection: 2021-09-28 08:56:14.403--Thread(Thread[main,5,main])--Detected database platform: org.eclipse.persistence.platform.database.MySQLPlatform [EL Config]: connection: 2021-09-28 08:56:14.423--ServerSession(712627377)--Connection(741883443)--Thread(Thread[main,5,main])--connecting(DatabaseLogin( platform=>MySQLPlatform user name=> "root" datasource URL=> "jdbc:mysql://127.0.0.1:3306/tutorialspoint?useSSL=false" )) [EL Config]: connection: 2021-09-28 08:56:14.469--ServerSession(712627377)--Connection(2134915053)--Thread(Thread[main,5,main])--Connected: jdbc:mysql://127.0.0.1:3306/tutorialspoint?useSSL=false User: root@localhost Database: MySQL Version: 8.0.23 Driver: MySQL Connector/J Version: mysql-connector-java-8.0.13 (Revision: 66459e9d39c8fd09767992bc592acd2053279be6) [EL Info]: connection: 2021-09-28 08:56:14.539--ServerSession(712627377)--Thread(Thread[main,5,main])--file:/F:/Workspace/springorm/target/classes/_EclipseLink_JPA login successful [EL Fine]: sql: 2021-09-28 08:56:14.602--ServerSession(712627377)--Connection(2134915053)--Thread(Thread[main,5,main])--CREATE TABLE Employees (ID INTEGER AUTO_INCREMENT NOT NULL, DESIGNATION VARCHAR(255), NAME VARCHAR(255), SALARY DOUBLE, PRIMARY KEY (ID)) [EL Fine]: sql: 2021-09-28 08:56:14.836--ClientSession(181326224)--Connection(2134915053)--Thread(Thread[main,5,main])--INSERT INTO Employees (DESIGNATION, NAME, SALARY) VALUES (?, ?, ?) bind => [Technical Manager, Julie, 10000.0] [EL Fine]: sql: 2021-09-28 08:56:14.855--ClientSession(181326224)--Connection(2134915053)--Thread(Thread[main,5,main])--SELECT LAST_INSERT_ID() [EL Fine]: sql: 2021-09-28 08:56:14.883--ClientSession(1573125303)--Connection(2134915053)--Thread(Thread[main,5,main])--INSERT INTO Employees (DESIGNATION, NAME, SALARY) VALUES (?, ?, ?) bind => [Senior Manager, Robert, 20000.0] [EL Fine]: sql: 2021-09-28 08:56:14.885--ClientSession(1573125303)--Connection(2134915053)--Thread(Thread[main,5,main])--SELECT LAST_INSERT_ID() [EL Fine]: sql: 2021-09-28 08:56:14.893--ClientSession(2054787417)--Connection(2134915053)--Thread(Thread[main,5,main])--INSERT INTO Employees (DESIGNATION, NAME, SALARY) VALUES (?, ?, ?) bind => [Software Engineer, Anil, 5000.0] [EL Fine]: sql: 2021-09-28 08:56:14.896--ClientSession(2054787417)--Connection(2134915053)--Thread(Thread[main,5,main])--SELECT LAST_INSERT_ID() [EL Fine]: sql: 2021-09-28 08:56:14.929--ServerSession(712627377)--Connection(2134915053)--Thread(Thread[main,5,main])--SELECT ID, DESIGNATION, NAME, SALARY FROM Employees Id : 1 Name : Julie Salary = 10000.0 Designation = Technical Manager Id : 2 Name : Robert Salary = 20000.0 Designation = Senior Manager Id : 3 Name : Anil Salary = 5000.0 Designation = Software Engineer Sep 28, 2021 8:56:14 AM org.springframework.context.annotation.AnnotationConfigApplicationContext doClose INFO: Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@5383967b: startup date [Tue Sep 28 08:56:12 IST 2021]; root of context hierarchy [EL Config]: connection: 2021-09-28 08:56:14.935--ServerSession(712627377)--Connection(2134915053)--Thread(Thread[main,5,main])--disconnect Sep 28, 2021 8:56:14 AM org.springframework.orm.jpa.LocalEntityManagerFactoryBean destroy INFO: Closing JPA EntityManagerFactory for persistence unit 'EclipseLink_JPA' [EL Info]: connection: 2021-09-28 08:56:14.936--ServerSession(712627377)--Thread(Thread[main,5,main])--file:/F:/Workspace/springorm/target/classes/_EclipseLink_JPA logout successful [EL Config]: connection: 2021-09-28 08:56:14.936--ServerSession(712627377)--Connection(741883443)--Thread(Thread[main,5,main])--disconnect
在此使用 Spring 配置构建并运行项目。创建一个 Employee 表,并含有三条记录。你可以使用 MySQL 控制台验证这一点。
Enter password: ******** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 41 Server version: 8.0.23 MySQL Community Server - GPL Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use tutorialspoint; Database changed mysql> select * from employees; +----+-------------------+--------+--------+ | id | DESIGNATION | NAME | SALARY | +----+-------------------+--------+--------+ | 1 | Technical Manager | Julie | 10000 | | 2 | Senior Manager | Robert | 20000 | | 3 | Software Engineer | Anil | 5000 | +----+-------------------+--------+--------+ 3 rows in set (0.00 sec) mysql>
广告