Note that there are some explanatory texts on larger screens.

plurals
  1. POhibernate double logging
    text
    copied!<p>I am working on a project using Spring, hibernate and struts2. Queries and system outs are being logged twice. I do have slf4j-api-1.6.1 and slf4j-log4j12-1.6.1 jars in lib folder.</p> <p>log4j.properties</p> <pre><code>log4j.logger.org.hibernate=info </code></pre> <p>applicationContext.html</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"&gt; &lt;!-- The singleton hibernate session factory --&gt; &lt;bean id="sessionFactory" scope="singleton" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt; &lt;property name="configLocation" value="classpath:hibernate.cfg.xml" /&gt; &lt;/bean&gt; &lt;!-- Spring's hibernate transaction manager, in charge of making hibernate sessions/txns --&gt; &lt;bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt; &lt;property name="sessionFactory" ref="sessionFactory" /&gt; &lt;/bean&gt; &lt;!-- So classes/functions with @Transactional get a hibernate txn --&gt; &lt;tx:annotation-driven /&gt; &lt;!-- Inject my business services class to the actions --&gt; &lt;bean id="services" class="dao.Services" scope="singleton"&gt; &lt;property name="sessionFactory" ref="sessionFactory" /&gt; &lt;/bean&gt; </code></pre> <p></p> <p>hibernate.cfg.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt; &lt;hibernate-configuration&gt; &lt;!-- Database connection settings --&gt; &lt;session-factory name=""&gt; &lt;property name="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt; &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://localhost/ciner&lt;/property&gt; &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt; &lt;property name="connection.password" /&gt; &lt;property name="connection.pool_size"&gt;1&lt;/property&gt; &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt; &lt;property name="hbm2ddl.auto"&gt;update&lt;/property&gt; &lt;!-- Exception was thrown. Thus removed, until fix is found. Enable c3p0 connection pooling, because hibernate pooling is not prod-ready. Apparently connection.provider_class is needed in hibernate 3+ &lt;property name="connection.provider_class"&gt;org.hibernate.connection.C3P0ConnectionProvider&lt;/property&gt; &lt;property name="c3p0.max_size"&gt;100&lt;/property&gt; &lt;property name="c3p0.min_size"&gt;1&lt;/property&gt; &lt;property name="c3p0.idle_test_period"&gt;30&lt;/property&gt; Echo all executed SQL to stdout for debugging --&gt; &lt;property name="show_sql"&gt;true&lt;/property&gt; &lt;property name="format_sql"&gt;true&lt;/property&gt; &lt;!-- All the entity classes for hibernate to check for annotations here --&gt; &lt;/session-factory&gt; &lt;/hibernate-configuration&gt; </code></pre> <p>struts.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"&gt; &lt;struts&gt; &lt;!-- set to false for prod --&gt; &lt;constant name="struts.devMode" value="true" /&gt; &lt;package name="default" extends="struts-default"&gt; &lt;/package&gt; &lt;/struts&gt; </code></pre> <p>Output</p> <pre><code>20:57:23,338 INFO [STDOUT] Hibernate: select newhire0_.employee_id as employee1_10_, newhire0_.active_status as active2_10_, newhire0_.cost_center as cost3_10_, newhire0_.credit_training as credit4_10_, newhire0_.development_plan as developm5_10_, newhire0_.development_session as developm6_10_, newhire0_.development_training as developm7_10_, newhire0_.employee_market as employee8_10_, newhire0_.end_date as end9_10_, newhire0_.first_offer_letter_sent as first10_10_, newhire0_.hire_date as hire11_10_, newhire0_.housing_required as housing12_10_, newhire0_.last_review_date as last13_10_, newhire0_.last_review_type as last14_10_, newhire0_.last_reviewer_name as last15_10_, newhire0_.new_hire_first_name as new16_10_, newhire0_.new_hire_last_name as new17_10_, newhire0_.lob_id as lob18_10_, from ciner.new_hire newhire0_ order by newhire0_.hire_date, newhire0_.lob_id, newhire0_.new_hire_last_name, newhire0_.new_hire_first_name 20:57:24,458 INFO [STDOUT] Hibernate: select newhire0_.employee_id as employee1_10_, newhire0_.active_status as active2_10_, newhire0_.cost_center as cost3_10_, newhire0_.credit_training as credit4_10_, newhire0_.development_plan as developm5_10_, newhire0_.development_session as developm6_10_, newhire0_.development_training as developm7_10_, newhire0_.employee_market as employee8_10_, newhire0_.end_date as end9_10_, newhire0_.first_offer_letter_sent as first10_10_, newhire0_.hire_date as hire11_10_, newhire0_.housing_required as housing12_10_, newhire0_.last_review_date as last13_10_, newhire0_.last_review_type as last14_10_, newhire0_.last_reviewer_name as last15_10_, newhire0_.new_hire_first_name as new16_10_, newhire0_.new_hire_last_name as new17_10_, newhire0_.lob_id as lob18_10_, from ciner.new_hire newhire0_ order by newhire0_.hire_date, newhire0_.lob_id, newhire0_.new_hire_last_name, newhire0_.new_hire_first_name 20:57:24,962 INFO [STDOUT] FA/2010, Chief Information Officer, John Doe1 20:57:24,962 INFO [STDOUT] SP/2010, Unknown, John Doe2 20:57:24,962 INFO [STDOUT] SP/2010, Chief Information Officer, John Doe3 20:57:24,990 INFO [STDOUT] FA/2010, Chief Information Officer, John Doe1 20:57:24,990 INFO [STDOUT] SP/2010, Unknown, John Doe2 20:57:24,991 INFO [STDOUT] SP/2010, Chief Information Officer, John Doe3 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload