无法使用Spring JPA供应商适配器使休眠停止显示SQL [英] Can't make hibernate stop showing SQL using Spring JPA Vendor Adapter
问题描述
< 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屋!