When debugging or executing the application queries are not getting printed in the console. I am using java 1.8, hibernate 5 and jboss7. For logging purpose log4j-1.2.17.jar is used. Is this problem due to any configuration or is it because of the log4j jar version issue?
Please check the property in your hibernate config xml
<!--hibernate.cfg.xml -->
<property name="show_sql">true</property>
for additional thing you can set these properties
Format the generated SQL statement to make it more readable, but takes up more screen space -
<!--hibernate.cfg.xml -->
<property name="format_sql">true</property>
Hibernate will put comments inside all generated SQL statements to hint what's the generated SQL trying to do -
<!--hibernate.cfg.xml -->
<property name="use_sql_comments">true</property>
From log4j side check this (for detailed logs - set it as DEBUG)
log4j.logger.org.hibernate=info
in XML version of log4j config file:
<logger name="org.hibernate">
<level value="info"/>
</logger>
This is because hiberante has cached the results and not going to the database to fetch the records.
Try a different record and you should see the select statement on the console
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.