GiriByaks
GiriByaks

Reputation: 941

Hibernate not printing HQL in the log

Hibernate is printing the HQL as null in the log files(Example below). The text printed looks like the summary of the query executed. How do I get it to print the actual HQL.

HQL: null, time: 0ms, rows: 4

Below is the code which results in this log statement

Criteria criteria = session.createCriteria( DataHolder.class );
criteria.setCacheable( true );
List data = criteria.add(Restrictions.naturalId().set( "sno", sno )).list();

log4j config
log4j.logger.org.hibernate=info

Upvotes: 1

Views: 3324

Answers (1)

Shervin Asgari
Shervin Asgari

Reputation: 24507

You probably need to define hibernate to print the sql in the first place in persistence.xml

 <property name="hibernate.show_sql" value="true"/>
 <property name="hibernate.format_sql" value="true"/>

The latter is not needed, but useful

Upvotes: 0

Related Questions