-->
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.  [ 3 posts ] 
Author Message
 Post subject: show_sql output format modification?
PostPosted: Thu Jul 21, 2005 1:58 pm 
Newbie

Joined: Thu Nov 18, 2004 6:51 pm
Posts: 10
Location: Arizona
First off, I looked at several posts relating to hibernate.show_sql, sql output etc. but I did not see any that address what I am interested in.

With hibernate.show_sql="true" in Hibernate 3.0.5 the engine outputs SQL like the following:
Code:
Hibernate: insert into GST_PERSON_ROLE (ROLE_ID) values (?)

Is it possible to have it output the actual values? (ie. something like the following, where the values are displayed not as '?' but as the actual data...or a truncated version of the data values):
Code:
Hibernate: insert into GST_PERSON_ROLE (ROLE_ID) values (32)




Q: If there isn't anything currently available, is there a "best practice" for intercepting/extending this behavior?

Again, if this has already been answered, my apologies, but please provide the link to the answer if that is the case.

Thanks in advance,
John


Top
 Profile  
 
 Post subject: Re: show_sql output format modification?
PostPosted: Thu Jul 21, 2005 3:01 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
javapda wrote:
First off, I looked at several posts relating to hibernate.show_sql, sql output etc. but I did not see any that address what I am interested in.

With hibernate.show_sql="true" in Hibernate 3.0.5 the engine outputs SQL like the following:
Code:
Hibernate: insert into GST_PERSON_ROLE (ROLE_ID) values (?)

Is it possible to have it output the actual values? (ie. something like the following, where the values are displayed not as '?' but as the actual data...or a truncated version of the data values):
Code:
Hibernate: insert into GST_PERSON_ROLE (ROLE_ID) values (32)




Q: If there isn't anything currently available, is there a "best practice" for intercepting/extending this behavior?

Again, if this has already been answered, my apologies, but please provide the link to the answer if that is the case.

Thanks in advance,
John


If you set your log-level to DEBUG you will get the values, just a little further down the log
Code:
2005-07-21 14:59:31,078 INFO  [STDOUT] Hibernate: select programmod0_.CHILD_SRVC_PLN_ID as CHILD2_1_ from SRVC_PLN_HEIRARCHY programmod0_ inner join SRVC_PLN programmod1_ on programmod0_.PARENT_SRVC_PLN_ID=programmod1_.SRVC_PLN_ID where programmod0_.CHILD_SRVC_PLN_ID=? order by programmod0_.SRVC_PLN_HEIRARCHY_ID
2005-07-21 14:59:31,078 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2005-07-21 14:59:31,078 DEBUG [org.hibernate.type.LongType] binding '84505' to parameter: 1


Top
 Profile  
 
 Post subject: Re: show_sql output format modification?
PostPosted: Thu Jul 21, 2005 4:58 pm 
Newbie

Joined: Thu Nov 18, 2004 6:51 pm
Posts: 10
Location: Arizona
Thanks pksiv,

While that is helpful info, it is not exactly what I am looking for. I would like to isolate the sql call and, perhaps, replace each '?' with a formatted version of the data.

In
Quote:
org.hibernate.jdbc.AbstractBatcher
there is a log call which dumps the sql to System.out. So it appears that the sql statement has been pre-prepared and then stored and retrieved. And based on the hibernate.show_sql it is output to the console.

I suppose to do what I am asking would be to intercept the sql at the point where it is executed and resolve each '?' with an array of objects.





pksiv wrote:
javapda wrote:
First off, I looked at several posts relating to hibernate.show_sql, sql output etc. but I did not see any that address what I am interested in.

With hibernate.show_sql="true" in Hibernate 3.0.5 the engine outputs SQL like the following:
Code:
Hibernate: insert into GST_PERSON_ROLE (ROLE_ID) values (?)

Is it possible to have it output the actual values? (ie. something like the following, where the values are displayed not as '?' but as the actual data...or a truncated version of the data values):
Code:
Hibernate: insert into GST_PERSON_ROLE (ROLE_ID) values (32)




Q: If there isn't anything currently available, is there a "best practice" for intercepting/extending this behavior?

Again, if this has already been answered, my apologies, but please provide the link to the answer if that is the case.

Thanks in advance,
John


If you set your log-level to DEBUG you will get the values, just a little further down the log
Code:
2005-07-21 14:59:31,078 INFO  [STDOUT] Hibernate: select programmod0_.CHILD_SRVC_PLN_ID as CHILD2_1_ from SRVC_PLN_HEIRARCHY programmod0_ inner join SRVC_PLN programmod1_ on programmod0_.PARENT_SRVC_PLN_ID=programmod1_.SRVC_PLN_ID where programmod0_.CHILD_SRVC_PLN_ID=? order by programmod0_.SRVC_PLN_HEIRARCHY_ID
2005-07-21 14:59:31,078 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2005-07-21 14:59:31,078 DEBUG [org.hibernate.type.LongType] binding '84505' to parameter: 1


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.