Help us understand the problem. What is going on with this article?

Display SQL statement generated by Hibernate JPA in Spring Boot environment

Setup

I will show it by using my notice board example application (Spring Data JPA version). On file src/main/resources/application.properties, add following line

# if you set debug=true, no need to add first line
logging.level.org.hibernate.SQL=trace

logging.level.org.hibernate.type=trace

Start the application, you can see following log message on loading some page.

## SQL statement generated by JPA vendor library, "?" is place of parameter put into
2019-09-18 12:00:53.660 DEBUG 1436 --- [nio-8080-exec-4] org.hibernate.SQL                        : select message0_.id as id1_1_, message0_.approved_by as approved2_1_, message0_.approved_date as approved3_1_, message0_.description as descript4_1_, message0_.owner as owner5_1_, message0_.publish_date as publish_6_1_, message0_.remove_date as remove_d7_1_ from message message0_ where message0_.owner=? order by message0_.publish_date DESC
## first parameter bind into SQL statement
2019-09-18 12:00:53.660 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [VARCHAR] - [user1]

## 1st record returned
2019-09-18 12:00:53.661 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([id1_1_] : [BIGINT]) - [4]
2019-09-18 12:00:53.662 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([approved2_1_] : [VARCHAR]) - [null]
2019-09-18 12:00:53.662 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([approved3_1_] : [TIMESTAMP]) - [null]
2019-09-18 12:00:53.663 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([descript4_1_] : [VARCHAR]) - [Waiting approve message 1]
2019-09-18 12:00:53.663 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([owner5_1_] : [VARCHAR]) - [user1]
2019-09-18 12:00:53.663 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([publish_6_1_] : [TIMESTAMP]) - [2019-08-03T10:00]
2019-09-18 12:00:53.663 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([remove_d7_1_] : [TIMESTAMP]) - [null]
## 2nd record returned
2019-09-18 12:00:53.663 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([id1_1_] : [BIGINT]) - [5]
2019-09-18 12:00:53.664 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([approved2_1_] : [VARCHAR]) - [null]
2019-09-18 12:00:53.664 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([approved3_1_] : [TIMESTAMP]) - [null]
2019-09-18 12:00:53.664 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([descript4_1_] : [VARCHAR]) - [Waiting approve message 2]
2019-09-18 12:00:53.664 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([owner5_1_] : [VARCHAR]) - [user1]
2019-09-18 12:00:53.664 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([publish_6_1_] : [TIMESTAMP]) - [2019-08-03T10:00]
2019-09-18 12:00:53.664 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([remove_d7_1_] : [TIMESTAMP]) - [null]
## 3rd record returned
2019-09-18 12:00:53.664 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([id1_1_] : [BIGINT]) - [1]
2019-09-18 12:00:53.664 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([approved2_1_] : [VARCHAR]) - [admin]
2019-09-18 12:00:53.664 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([approved3_1_] : [TIMESTAMP]) - [2019-07-31T21:00]
2019-09-18 12:00:53.664 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([descript4_1_] : [VARCHAR]) - [Hello world]
2019-09-18 12:00:53.664 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([owner5_1_] : [VARCHAR]) - [user1]
2019-09-18 12:00:53.665 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([publish_6_1_] : [TIMESTAMP]) - [2019-08-01T12:30]
2019-09-18 12:00:53.665 TRACE 1436 --- [nio-8080-exec-4] o.h.type.descriptor.sql.BasicExtractor   : extracted value ([remove_d7_1_] : [TIMESTAMP]) - [null]
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away