-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Log Hibernate problem
PostPosted: Wed Nov 22, 2006 8:37 am 
Newbie

Joined: Wed Nov 22, 2006 8:13 am
Posts: 1
I have a problem: I want to analyze my log application, but it doesn´t show me the SQL instruction with their parameters. It shows only "?".

The current log as follow:

Hibernate: insert into Cliente (dcNome, dcCpfCnpj, dcWebsite, dcEmail, pnCliente) values (?, ?, ?, ?, ?)
Hibernate: insert into IdentificaCliente (dcChave, dcLogin, dcSenha, pnidentificacliente) values (?, ?, ?, ?)
Hibernate: insert into Telefone (dcContato, dcNumTel, fncliente, fntipotel, fnddd, pnTelefone) values (?, ?, ?, ?, ?, ?)
Hibernate: insert into Telefone (dcContato, dcNumTel, fncliente, fntipotel, fnddd, pnTelefone) values (?, ?, ?, ?, ?, ?)
Hibernate: insert into Telefone (dcContato, dcNumTel, fncliente, fntipotel, fnddd, pnTelefone) values (?, ?, ?, ?, ?, ?)

I need to analyze the value of ?. For example, I need the SQL instruction as follow:
Hibernate: insert into Cliente (dcNome, dcCpfCnpj, dcWebsite, dcEmail, pnCliente) values ('Rodrigo', '333333', 'HTTP:\\', 'rodrigo@teste.com.br', 5)

Therefore I don´t know how to configure my log hibernate.

Best regards,


Top
 Profile  
 
 Post subject: Connection wrapper
PostPosted: Thu Nov 23, 2006 3:48 pm 
Newbie

Joined: Mon Aug 02, 2004 1:21 pm
Posts: 9
Hi,

One way to do this is by using a connection wrapper that logs statements.

Just create a custom connection provider and plug your wrapper into hibernate.

See chapter 3.3 of the manual to see how to do this.

_________________
Camilo A.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 23, 2006 7:17 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
You won't be able to display the SQL with used values directly by only configuring Hibernate. Hibernate is using sql parametrized queries.

I mean, there are two ways I see :
* As camilosaurio says, it's possible to use a false jdbc wrapper that would display the real sql executed on the server. Don't remember the names of these products at the moment :-/
* a quick work-around, although I do not find it very readable, is to display the values that H3 passes in those parameters, activating org.hibernate.type in debug in log4j.properties (recall that org.hibernate.SQL=debug provides you with the same as show_sql=true in hbm properties).

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 23, 2006 8:07 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
You can try configuring the "org.hibernate.type" category to go to where ever you configured "org.hibernate.SQL" to log to.

This will give you a log that looks like this:
Code:
18:01:52.530 [main] select structural0_.id ... where upper(structural0_.name) like upper(?)
18:01:52.702 [main] binding '%orgName1164268912187%' to parameter: 1


So you can see the bind values, but you have to figure out where they go in the statement yourself.

You can use a tool like P6Spy (unsupported these days, but still works) to show you an estimation of what the SQL as executed by the DB engine will look like.

_________________
Cheers,
Shorn.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.