hello all,
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.
log4j.properties
log4j.logger.org.hibernate=info
applicationContext.html
<?xml version="1.0" encoding="UTF-8"?>
<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">
<!-- The singleton hibernate session factory -->
<bean id="sessionFactory" scope="singleton"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
</bean>
<!-- Spring's hibernate transaction manager, in charge of making hibernate sessions/txns -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- So classes/functions with @Transactional get a hibernate txn -->
<tx:annotation-driven />
<!-- Inject my business services class to the actions -->
<bean id="services" class="dao.Services" scope="singleton">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<!-- Database connection settings -->
<session-factory name="">
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/ciner</property>
<property name="hibernate.connection.username">root</property>
<property name="connection.password" />
<property name="connection.pool_size">1</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hbm2ddl.auto">update</property>
<!--
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+
<property
name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="c3p0.max_size">100</property> <property
name="c3p0.min_size">1</property> <property
name="c3p0.idle_test_period">30</property> Echo all executed SQL to
stdout for debugging
-->
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<!--
All the entity classes for hibernate to check for annotations here
-->
</session-factory>
</hibernate-configuration>
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- set to false for prod -->
<constant name="struts.devMode" value="true" />
<package name="default" extends="struts-default">
</package>
</struts>
Output
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