Hibernate Statistics & Logging — Concept Check
Questions on Hibernate Statistics & Logging. Enable hibernate.generate_statistics and show_sql to see query counts, cache hit ratios, and connection acquisition time — essential for identifying performance bottlenecks.
Questions in this quiz
7 questions on Hibernate Statistics & Logging — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.During development, you notice a single API call executes over 100 queries. What might this indicate?
- AEfficient use of the second-level cache
- BAn N+1 problem in the fetch strategy
- CProper indexing of database tables
- DCorrect use of lazy loading
2.What does enabling 'hibernate.generate_statistics' in Hibernate achieve?
- AIt prevents SQL injection attacks
- BIt formats SQL queries for better readability
- CIt collects query execution and cache metrics
- DIt logs all SQL queries to a file
3.A developer sets 'show_sql' to true in production. What is a potential issue?
- ASQL queries will not be logged
- BIt will disable the second-level cache
- CExcessive logging can degrade performance
- DIt will automatically format SQL queries
4.Which metric would you monitor to detect an N+1 problem in production?
- AHigh query execution count per session
- BLow second-level cache hit ratio
- CLow entity load count
- DHigh connection acquisition time
5.How can you log slow queries in Hibernate during development?
- AEnable 'use_sql_comments'
- BSet 'session.events.log.LOG_QUERIES_SLOWER_THAN_MS' to a threshold
- CEnable 'hibernate.show_sql'
- DUse 'org.hibernate.SQL' logger at TRACE level
6.What does the 'org.hibernate.SQL' logger category do when set at DEBUG level?
- ADisables SQL query execution
- BRoutes SQL logging through SLF4J
- CPrevents SQL logging in production
- DFormats SQL queries for readability
7.In a Spring Boot application, how are Hibernate statistics exposed for monitoring?
- ABy enabling 'show_sql'
- BUsing 'use_sql_comments' for context
- CBy setting 'format_sql' to true
- DThrough Micrometer metrics