views:

3346

answers:

4

Hibernate is continuing to spew SQL traces to stdout, and I can't figure out how to change a Hibernate configuration property when it's hidden behind a JPA adapter. This is the Spring bean for the entityManagerFactory:

<bean id="entityManagerFactory" 
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="ssapDataSource"/>
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" >
            <property name="showSql" value="false"/>
        </bean>
    </property>
</bean>

Even with the showSql property set to false, Hibernate keeps printing SQL.

I've tried making a hibernate.properties file in my classpath with "hibernate.show_sql=false", but it didn't pick that up either.

+1  A: 

As far as I know, Hibernate will also log SQL statements if logging for org.hibernate.SQL happens at DEBUG or ALL level, so you could try disabling that (for example with log4j.logger.org.hibernate.SQL=info when using Log4J).

springify
Thanks, unfortunately I already have org.hibernate.SQL logging set to ERROR in log4j. :(
Mojo
A: 

If you are using spring make sure that you don't have the showSql property set to true

I was doing this myself

<bean id="vendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    <property name="showSql" value="false"/>
</bean>
A: 

Mojo,

I have the same issue. Were you able to figure this out?

Thanks,

No, I never solved the issue. Just gave up in this instance.
Mojo
A: 

Try setting it in persistance.xml

<persistence>
  <persistence-unit name="PU">
    <properties>
      <property name="hibernate.show_sql" value="false"/>
    </properties>
  </persistence-unit>
</persistence>
NA
The turns out to be exactly the issue. My "platform" library jar included a persistence.xml file that turns on show_sql, and isn't overridden at run time or Spring wire-up time.
Mojo