网学网为需要JAVA的朋友们搜集整理了Hibernate中的show_sql和Spring中的hibernate.show_sql的区别相关资料,希望对各位网友有所帮助!
Hibernate配置文件的属性是show_sql而Spring配置文件中的属性是hibernate.show_sql 其实Hiberante中用的也是hibernate.show_sql,只不过hibernate这段字符串是在org.hibernate.cfg.Configuration类的addProperties()方法中自动加上的: private void addProperties(Element parent) { Iterator iter = parent.elementIterator( "property" ); while ( iter.hasNext() ) { Element node = (Element) iter.next(); String name = node.attributeValue( "name" ); String value = node.getText().trim(); log.debug( name + "=" + value ); properties.setProperty( name, value ); if ( !name.startsWith( "hibernate" ) ) { //在这里加个hiberate字符串 properties.setProperty( "hibernate." + name, value ); } } Environment.verifyProperties( properties ); } 例如: Hibernate配置文件:<property name="show_sql">true</property><property name="connection.autocommit">false</property> <!-- 在Hibernate中默认为false --> Spring配置文件:<prop key="hibernate.show_sql">true</prop><prop key="hibernate.connection.autocommit">false</prop>