This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate entity manager: call to find() and showing SQL

 
Karsten Wutzke
Ranch Hand
Posts: 106
Hibernate MySQL Database Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

how do I show the SQL generated by Hibernate's entity manager on a failed call to find(... , ...)?

I have configured my persistence.xml with



What's wrong? I'd like to find the SQL that gets executed.

Karsten
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That should be logging SQL. Check your logger configuration - have you set a threshold higher than INFO?
 
Karsten Wutzke
Ranch Hand
Posts: 106
Hibernate MySQL Database Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hadn't actively configured logging when I posted. Tomcat was logging, so I implied Hibernate could, too. I'm using embedded JBoss on Tomcat 6, so I'm not sure if Hibernate logging is/was configured at all. There's a log4j.xml file in Tomcat's lib dir. I can't say if it's evaluated for the config at all. I found this in there:

I put 3 files onto my classpath, that is the Tomcat lib dir:

log4j-1.2.16.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar

I still don't get any SQL output when calling find() on the entity manager.

Any other ideas?

Karsten
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do any of your appenders have thresholds? A category enabled logging at a particular level for specific classes, thresholds filter out log messages for a specific appender. So logging could be anabled but hidden.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic