views:

1899

answers:

3

(see here for the problem I'm trying to solve)

How do you get hibernate to log clob values it's going to insert. It is logging other value types, such as Integer etc.

I have the following in my log4j config:

log4j.logger.net.sf.hibernate.SQL=DEBUG
log4j.logger.org.hibernate.SQL=DEBUG
log4j.logger.net.sf.hibernate.type=DEBUG
log4j.logger.org.hibernate.type=DEBUG

Which produces output such as:

(org.hibernate.SQL) insert into NoteSubstitutions (note, listIndex, substitution) values (?, ?, ?)
(org.hibernate.type.LongType) binding '170650' to parameter: 1
(org.hibernate.type.IntegerType) binding '0' to parameter: 2
(org.hibernate.SQL) insert into NoteSubstitutions (note, listIndex, substitution) values (?, ?, ?)
(org.hibernate.type.LongType) binding '170650' to parameter: 1
(org.hibernate.type.IntegerType) binding '1' to parameter: 2

However you'll note that it never displays parameter: 3 which is our clob.

What I would really want is something like:

(org.hibernate.SQL) insert into NoteSubstitutions (note, listIndex, substitution) values (?, ?, ?)
(org.hibernate.type.LongType) binding '170650' to parameter: 1
(org.hibernate.type.IntegerType) binding '0' to parameter: 2
(org.hibernate.type.ClobType) binding 'something' to parameter: 3
(org.hibernate.SQL) insert into NoteSubstitutions (note, listIndex, substitution) values (?, ?, ?)
(org.hibernate.type.LongType) binding '170650' to parameter: 1
(org.hibernate.type.IntegerType) binding '1' to parameter: 2
(org.hibernate.type.ClobType) binding 'something else' to parameter: 3

How do I get it to show this in the log?

A: 

Try using:

log4j.logger.net.sf.hibernate=DEBUG
log4j.logger.org.hibernate=DEBUG

That's the finest level you'll get. If it does not show the information you want, then it's not possible.

Marcio Aguiar
+1  A: 

Well, it looks like you can't. (Thanks Marcio for the suggestion, but sadly that didn't add anything useful)

SCdF
A: 

Try to set log4j.logger.org.hibernate.type=TRACE and see if that helps.

talg
Yeah, that didn't help either. I think it's just because you can't guarantee that a clob is dumpable to a console so it doesn't.
SCdF