Not getting parameter values using log4jdbc with Spring

348 views
Skip to first unread message

mallen

unread,
Mar 15, 2011, 11:44:27 AM3/15/11
to Hibernate Profiler
Hi,

I am doing some Java development after working on .Net exclusively for
the last 6+ years so I may be missing something obvious...
I've got profiling working apart from the parameter values do not
show.

Here is my sessionFactory bean definition

<bean id="sessionFactory"

class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="packagesToScan">
<list>
<value>com.ndl.helpdesk.**.*</value>
</list>
</property>
<property name="schemaUpdate" value="false"/>
<property name="hibernateProperties">
<props>
<prop
key="hibernate.connection.driver_class">net.sf.log4jdbc.DriverSpy</
prop>
<prop
key="hibernate.connection.url">jdbc:log4jdbc:hsqldb:mem:wind;user=sa</
prop>
<prop
key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
<prop key="hibernate.pool_size">1</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop
key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</
prop>
<prop key="hibernate.use_sql_comments">true</prop>
<prop
key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</
prop>
<prop key="hibernate.jdbc.batch_size">25</prop>
</props>
</property>
<hprof:profiler useSpy="true"/>
</bean>

in the log I can see log4jdbc being initailized eg

2011-03-15 15:20:54 debug [DEBUG] ... log4jdbc initializing ...
2011-03-15 15:20:54 debug [DEBUG] log4jdbc.properties not found on
classpath
2011-03-15 15:20:54 debug [DEBUG] x log4jdbc.debug.stack.prefix is not
defined
2011-03-15 15:20:54 debug [DEBUG] x log4jdbc.sqltiming.warn.threshold
is not defined
2011-03-15 15:20:54 debug [DEBUG] x log4jdbc.sqltiming.error.threshold
is not defined
2011-03-15 15:20:54 debug [DEBUG] x log4jdbc.dump.booleanastruefalse
is not defined (using default value false)
2011-03-15 15:20:54 debug [DEBUG] x log4jdbc.dump.sql.maxlinelength is
not defined (using default of 90)
2011-03-15 15:20:54 debug [DEBUG] x log4jdbc.dump.fulldebugstacktrace
is not defined (using default value false)
2011-03-15 15:20:54 debug [DEBUG] x log4jdbc.statement.warn is not
defined (using default value false)
2011-03-15 15:20:54 debug [DEBUG] x log4jdbc.dump.sql.select is not
defined (using default value true)
2011-03-15 15:20:54 debug [DEBUG] x log4jdbc.dump.sql.insert is not
defined (using default value true)
2011-03-15 15:20:54 debug [DEBUG] x log4jdbc.dump.sql.update is not
defined (using default value true)
2011-03-15 15:20:54 debug [DEBUG] x log4jdbc.dump.sql.delete is not
defined (using default value true)
2011-03-15 15:20:54 debug [DEBUG] x log4jdbc.dump.sql.create is not
defined (using default value true)
2011-03-15 15:20:54 debug [DEBUG] x log4jdbc.dump.sql.addsemicolon is
not defined (using default value false)
2011-03-15 15:20:54 debug [DEBUG] x log4jdbc.auto.load.popular.drivers
is not defined (using default value true)
2011-03-15 15:20:54 debug [DEBUG] x log4jdbc.trim.sql is not defined
(using default value true)
2011-03-15 15:20:54 debug [DEBUG] x
log4jdbc.suppress.generated.keys.exception is not defined (using
default value false)
2011-03-15 15:20:54 debug [DEBUG] x log4jdbc.drivers is not defined
2011-03-15 15:20:54 debug [DEBUG] FOUND DRIVER org.hsqldb.jdbcDriver
2011-03-15 15:20:54 debug [DEBUG] FOUND DRIVER org.postgresql.Driver
2011-03-15 15:20:54 debug [DEBUG] ... log4jdbc initialized! ...

further down the log log4jdbc seems to be logging the Hibernate
generated sql complete with parameters

2011-03-15 15:20:56 sqlonly [INFO] batching 1 statements: 1: /* insert
com.ndl.helpdesk.entities.HelpdeskContract */ insert into
helpdesk.contract (active, version, name, code, id) values (1, 0,
'TestContract', 'TC1', 1)

2011-03-15 15:20:56 sqlonly [INFO] /* load
com.ndl.helpdesk.entities.HelpdeskContract */ select helpdeskco0_.id
as id14_0_, helpdeskco0_.active
as active14_0_, helpdeskco0_.version as version14_0_,
helpdeskco0_.name as name14_0_, helpdeskco0_.code
as code14_0_ from helpdesk.contract helpdeskco0_ where
helpdeskco0_.id=1

What am I missing?

Thanks
Mark

Ayende Rahien

unread,
Mar 16, 2011, 5:06:50 AM3/16/11
to hibernate...@googlegroups.com, mallen
Are you seeing the statements in the profiler?

mallen

unread,
Mar 16, 2011, 6:46:31 AM3/16/11
to Hibernate Profiler
Yes I can see the statements in the profiler eg

/* insert com.ndl.helpdesk.entities.HelpdeskContract */


insert into helpdesk.contract
(active,
version,
name,
code,
id)
values (?,
?,
?,
?,
?)

However the parameters area to the right is blank.
> > key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTra nsactionFactory</

Ayende Rahien

unread,
Mar 16, 2011, 9:38:24 AM3/16/11
to hibernate...@googlegroups.com
What java version are you using?

mallen

unread,
Mar 17, 2011, 6:25:01 AM3/17/11
to Hibernate Profiler
Java 1.6

Spring 3.0.5
Hibernate-Core 3.6.2
Log4j 1.2.16
Log4jdbc 1.2beta2

Eric Hauser

unread,
Mar 20, 2011, 6:15:33 PM3/20/11
to hibernate...@googlegroups.com
It seems that you have included log4jdbc on your own, the profiler ships with a forked version of log4jdbc that you need to to use.  It is contained in the profiler's JAR, so there is nothing you need to add.  Your hibernate.connection.driver_class should look like this:


<prop key="hibernate.connection.driver_class">net.sf.log4jdbc.hibernateprofiler.jdbc4.DriverSpy</prop>

It wouldn't surprise if that won't work if you also have the log4jdbc JAR included in your application, so you should probably remove it.

mallen

unread,
Mar 21, 2011, 6:23:23 AM3/21/11
to Hibernate Profiler
That was it - its working perfectly now.

Thanks for your help

On Mar 20, 10:15 pm, Eric Hauser <ewhau...@gmail.com> wrote:
> It seems that you have included log4jdbc on your own, the profiler ships
> with a forked version of log4jdbc that you need to to use.  It is contained
> in the profiler's JAR, so there is nothing you need to add.  Your
> hibernate.connection.driver_class should look like this:
>
> <prop key="hibernate.connection.driver_class">net.sf.log4jdbc.hibernateprofiler.j dbc4.DriverSpy</prop>
Reply all
Reply to author
Forward
0 new messages