无法使用Spring JPA供应商适配器使休眠停止显示SQL [英] Can't make hibernate stop showing SQL using Spring JPA Vendor Adapter

查看:180
本文介绍了无法使用Spring JPA供应商适配器使休眠停止显示SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hibernate继续将SQL跟踪信息发布到标准输出,我无法弄清楚如何在隐藏在JPA适配器后面的情况下更改Hibernate配置属性。这是entityManagerFactory的Spring bean:

 < bean id =entityManagerFactory
class =org。 springframework.orm.jpa.LocalContainerEntityManagerFactoryBean>
< property name =dataSourceref =ssapDataSource/>
< property name =jpaVendorAdapter>
< bean class =org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter>
< property name =showSqlvalue =false/>
< / bean>
< / property>
< / bean>

即使将showSql属性设置为false,Hibernate也会继续打印SQL。



我尝试在类路径中使用hibernate.show_sql = false创建一个hibernate.properties文件,但它没有选择它。

 < persistence> class =h2_lin>解决方案


< persistence-unit name =PU>
<属性>
< property name =hibernate.show_sqlvalue =false/>
< / properties>
< / persistence-unit>
< /余辉>


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.

解决方案

Try setting it in persistance.xml

<persistence>
  <persistence-unit name="PU">
    <properties>
      <property name="hibernate.show_sql" value="false"/>
    </properties>
  </persistence-unit>
</persistence>

这篇关于无法使用Spring JPA供应商适配器使休眠停止显示SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆