Home > Mobile >  Where is the sql so I can see the criteria that hibernate repository uses to filter out records in f
Where is the sql so I can see the criteria that hibernate repository uses to filter out records in f

Time:10-07

I have an Oracle table mapped to a Hibernate repository.

In the code I only see

public interface MyTableRepository extends JpaRepository<MyTableRacord, Long> {
}

Where is the sql that findById(Long id) uses?

What criteria is it using to filter out the records?

CodePudding user response:

if you are using spring-boot you could change log level in properties and get all statement SQL have used for Hibernate

# SETTINGS FOR MORE DETAILS ON HIBERNATE
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.use_sql_comments=true
spring.jpa.properties.hibernate.format_sql=true

# CHANGE LEVEL LOG FOR HIBERNATE
logging.level.org.hibernate.type=TRACE

# CHANGE LEVEL LOG FOR SPRING JDBC
logging.level.org.springframework.jdbc=TRACE

## YOU CAN USE 'INFO' OR 'DEBUG' INSTEAD OF 'TRACE' AS YOU PREFER

  • Related