Announcement Announcement Module
Collapse
No announcement yet.
Spring + Hibernate ignores show_sql Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring + Hibernate ignores show_sql

    Hello

    I tried to set the show_sql attribute of hibernate in to different ways.

    1. via the hibernate.properties

    Code:
    <?xml version='1.0' encoding='utf-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
       "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
       "http&#58;//hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
       <session-factory>
       
          
          <property name="show_sql">true</property>
          <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
         
    
       </session-factory>
    </hibernate-configuration>

    2. via the Spring config file

    Code:
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		
    		<property name="hibernateProperties">
    			<props>
    			<prop key="hibernate.show_sql">true</prop>
    			
    			</props>
    		
    		</property>
    		
    		<property name="dataSource">
    			<ref bean="dataSource"/>
    		</property>
    		
    		<property name="mappingDirectoryLocations">
    			<list>
    				<value>classpath&#58;/com/praemed/database/data</value>
    			</list>
    		
    		</property>
    	</bean>
    Unfortunately the log file tells me in both situations

    Code:
    2005-06-21 09&#58;40&#58;17,271 INFO &#91;org.hibernate.cfg.SettingsFactory&#93; - JDBC driver&#58; Oracle JDBC driver, version&#58; 9.2.0.1.0
    2005-06-21 09&#58;40&#58;17,301 INFO &#91;org.hibernate.dialect.Dialect&#93; - Using dialect&#58; org.hibernate.dialect.Oracle9Dialect
    2005-06-21 09&#58;40&#58;17,311 INFO &#91;org.hibernate.transaction.TransactionFactoryFactory&#93; - Using default transaction strategy &#40;direct JDBC transactions&#41;
    2005-06-21 09&#58;40&#58;17,311 INFO &#91;org.hibernate.transaction.TransactionManagerLookupFactory&#93; - No TransactionManagerLookup configured &#40;in JTA environment, use of read-write or transactional second-level cache is not recommended&#41;
    2005-06-21 09&#58;40&#58;17,311 INFO &#91;org.hibernate.cfg.SettingsFactory&#93; - Automatic flush during beforeCompletion&#40;&#41;&#58; disabled
    2005-06-21 09&#58;40&#58;17,311 INFO &#91;org.hibernate.cfg.SettingsFactory&#93; - Automatic session close at end of transaction&#58; disabled
    2005-06-21 09&#58;40&#58;17,311 INFO &#91;org.hibernate.cfg.SettingsFactory&#93; - JDBC batch size&#58; 15
    2005-06-21 09&#58;40&#58;17,311 INFO &#91;org.hibernate.cfg.SettingsFactory&#93; - JDBC batch updates for versioned data&#58; disabled
    2005-06-21 09&#58;40&#58;17,321 INFO &#91;org.hibernate.cfg.SettingsFactory&#93; - Scrollable result sets&#58; enabled
    2005-06-21 09&#58;40&#58;17,321 INFO &#91;org.hibernate.cfg.SettingsFactory&#93; - JDBC3 getGeneratedKeys&#40;&#41;&#58; disabled
    2005-06-21 09&#58;40&#58;17,321 INFO &#91;org.hibernate.cfg.SettingsFactory&#93; - Connection release mode&#58; null
    2005-06-21 09&#58;40&#58;17,321 INFO &#91;org.hibernate.cfg.SettingsFactory&#93; - Default batch fetch size&#58; 1
    2005-06-21 09&#58;40&#58;17,321 INFO &#91;org.hibernate.cfg.SettingsFactory&#93; - Generate SQL with comments&#58; disabled
    and no SQL Code is displayed, but he has no problems with the dialect attribute.

    TIA

    Best regards
    Johan

  • #2
    Strange...both these options work for me.

    If using the first option, make sure you include the configLocation property:
    Code:
    	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSource"><ref local="dataSource"/></property>
    		<property name="configLocation"><value>classpath&#58;hibernate.cfg.xml</value></property> 
       ...
    With the second option, make sure you are injecting the session into the right objects.

    Comment

    Working...
    X