Spring ORM – Run & Test Hibernate


Spring ORM – Run & Test Hibernate



”;


Now in eclipse, right click on the MainApp.java, select Run As context menu, and select Java Application. Check the console logs in the eclipse. You can see the below logs −


...
Sep 27, 2021 9:16:52 AM org.springframework.orm.jpa.LocalEntityManagerFactoryBean createNativeEntityManagerFactory
INFO: Building JPA EntityManagerFactory for persistence unit ''Hibernate_JPA''
Sep 27, 2021 9:16:52 AM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation
INFO: HHH000204: Processing PersistenceUnitInfo [name: Hibernate_JPA...]
...
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
Hibernate: drop table if exists Employees
Sep 27, 2021 9:16:54 AM org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection
INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@2264ea32] for (non-JTA) DDL execution was not in auto-commit mode; the Connection ''local transaction'' will be committed and the Connection will be set into auto-commit mode.
Hibernate: create table Employees (id integer not null auto_increment, DESIGNATION varchar(255), NAME varchar(255), SALARY double precision, primary key (id)) engine=MyISAM
Sep 27, 2021 9:16:54 AM org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection
INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@58740366] for (non-JTA) DDL execution was not in auto-commit mode; the Connection ''local transaction'' will be committed and the Connection will be set into auto-commit mode.
Sep 27, 2021 9:16:54 AM org.hibernate.tool.schema.internal.SchemaCreatorImpl applyImportSources
INFO: HHH000476: Executing import script ''org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@4b74b35''
Sep 27, 2021 9:16:54 AM org.springframework.orm.jpa.LocalEntityManagerFactoryBean buildNativeEntityManagerFactory
INFO: Initialized JPA EntityManagerFactory for persistence unit ''Hibernate_JPA''
Hibernate: insert into Employees (DESIGNATION, NAME, SALARY) values (?, ?, ?)
Hibernate: insert into Employees (DESIGNATION, NAME, SALARY) values (?, ?, ?)
Hibernate: insert into Employees (DESIGNATION, NAME, SALARY) values (?, ?, ?)
Sep 27, 2021 9:16:55 AM org.hibernate.hql.internal.QueryTranslatorFactoryInitiator initiateService
INFO: HHH000397: Using ASTQueryTranslatorFactory
Hibernate: select employee0_.id as id1_0_, employee0_.DESIGNATION as DESIGNAT2_0_, employee0_.NAME as NAME3_0_, employee0_.SALARY as SALARY4_0_ from Employees employee0_
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 27, 2021 9:16:55 AM org.springframework.context.annotation.AnnotationConfigApplicationContext doClose
INFO: Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@18eed359: startup date [Mon Sep 27 09:16:51 IST 2021]; root of context hierarchy
Sep 27, 2021 9:16:55 AM org.springframework.orm.jpa.LocalEntityManagerFactoryBean destroy
INFO: Closing JPA EntityManagerFactory for persistence unit ''Hibernate_JPA''
Sep 27, 2021 9:16:55 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl stop
INFO: HHH10001008: Cleaning up connection pool [jdbc:mysql://localhost:3306/tutorialspoint?useSSL=false]

Here project is built and run using spring configurations. A table Employee is created and have three records. You can verify the same using MySQL console.


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>

Advertisements

”;

Leave a Reply

Your email address will not be published. Required fields are marked *