permaculture playing cards*
The moose likes Object Relational Mapping and the fly likes Hibernate entity manager: call to find() and showing SQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate entity manager: call to find() and showing SQL" Watch "Hibernate entity manager: call to find() and showing SQL" New topic
Author

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

Karsten Wutzke
Ranch Hand

Joined: Jul 20, 2010
Posts: 106

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


OCJP JavaSE 6 (86%)
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

That should be logging SQL. Check your logger configuration - have you set a threshold higher than INFO?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Karsten Wutzke
Ranch Hand

Joined: Jul 20, 2010
Posts: 106

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

Joined: Apr 14, 2004
Posts: 10336

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.
 
 
subject: Hibernate entity manager: call to find() and showing SQL
 
Similar Threads
JPA, Spring and hibernate.ejb.interceptor
Hibernate using datetime2 with SQLServer2005 instead of datetime
Criteria to SQL
problem while deploying in glassfish
java.lang.IllegalArgumentException: Unknown entity