Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What class in Hibernate generates the SQL statements that gets logged?

I'm having trouble with an ObjectNotFoundException where Hibernate appears to be performing a select statement where I didn't expect it too, due to lazy loading being true. I suspect something to do with AOP, but I can't change anything since I'm using someone else's framework.

I was thinking of putting a breakpoint in the place where the select statement gets generated into my log, that way I can see who's triggering it. What's the Hibernate class I should be setting breakpoints on?

like image 236
aberrant80 Avatar asked Jul 27 '11 10:07

aberrant80


2 Answers

I believe that the log entry is generated within org.hibernate.jdbc.util.SQLStatementLogger

like image 92
teabot Avatar answered Oct 04 '22 20:10

teabot


Hell is other people's frameworks. You can see Hibernate logging its SQL if you configure log4j to get debug-level logging for org.hibernate.SQL and trace-level logging for org.hibernate.type. But Hibernate's SQL generation happens a long way from where it decides what it needs to do, so I doubt that will help. The SessionImpl has an ActionQueue that lists the actions Hibernate will take, you may want to watch what gets shown there.

like image 44
Nathan Hughes Avatar answered Oct 04 '22 19:10

Nathan Hughes