-->
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.  [ 11 posts ] 
Author Message
 Post subject: viewing sql values
PostPosted: Tue Feb 07, 2006 12:48 pm 
Newbie

Joined: Tue Feb 07, 2006 12:42 pm
Posts: 4
Is there a way to view the actual SQL statement being executed with the values? I'm getting an error on an insert statement, but cannot view the values being inserted so am unable to debug.

My error is SQL Error: 0, SQLState: 01004
Data Truncation
Could not synchronize database state with session


My update statement does work, just not the insert statement.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 07, 2006 7:12 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Set the approrpiate logging level and you will see the values.


Top
 Profile  
 
 Post subject: Re: viewing sql values
PostPosted: Wed Feb 08, 2006 7:00 am 
Beginner
Beginner

Joined: Mon Jan 30, 2006 2:28 am
Posts: 47
Location: INDIA
Hi thuhman,
1. Try to to insert show_sql=true in hibernate.hbm.xml file in between

<session-factory></session-factory> these two tags.

eg.
<session-factory >
................
....................
<property name="show_sql">true</property>
..................
<session-factory>

2. or Try to print your insert query name using System.out.println(query) simply and see the console.

Thanks

_________________
A.Edward Durai
"The things which are impossible with men are possible with God."


Top
 Profile  
 
 Post subject: Use spy driver.
PostPosted: Wed Feb 08, 2006 10:19 am 
Newbie

Joined: Wed Feb 08, 2006 10:02 am
Posts: 2
Location: Fortaleza - CearĂ¡ - Brazil
Use a spy driver that intercept all sql statements and log.

See http://www.p6spy.com/

;)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 1:40 pm 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
set the level of org.hibernate.type logger to debug this will show the values being set for all the parameters.

As mentioned earlier P6Spy is also a good way to find this out.


Top
 Profile  
 
 Post subject: Changing the logger to debug
PostPosted: Thu Feb 09, 2006 4:43 pm 
Newbie

Joined: Tue Feb 07, 2006 12:42 pm
Posts: 4
This shows the values on a Select statement, but it still does not show the values on an update (the values are still shown in the logger as a ?). Any ideas?


Top
 Profile  
 
 Post subject: Changing the logger to debug
PostPosted: Thu Feb 09, 2006 4:45 pm 
Newbie

Joined: Tue Feb 07, 2006 12:42 pm
Posts: 4
Changing the org.hibernate logger does show the values on my Select statements, but it still does not show the values on an update (the values are still shown in the logger as a ?). Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 5:06 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
According to table 3.9 of the ref docs, the log4j.properties category you want is:
Quote:
org.hibernate.type | Log all JDBC parameters


Top
 Profile  
 
 Post subject: Re: Changing the logger to debug
PostPosted: Thu Feb 09, 2006 5:09 pm 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
thuhman wrote:
Changing the org.hibernate logger does show the values on my Select statements, but it still does not show the values on an update (the values are still shown in the logger as a ?). Any ideas?


which logger did you change?

as i mentioned earlier the logger you should enable debug logging is
org.hibernate.type.

you can turn debug log for org.hibernate but that will produce a lot of log which you may not need.


Top
 Profile  
 
 Post subject: org.hibernate.type
PostPosted: Thu Feb 09, 2006 5:26 pm 
Newbie

Joined: Tue Feb 07, 2006 12:42 pm
Posts: 4
I changed org.hibernate.type to debug, and it just showed the values for the select statements, not the values for the update statements. Maybe the P6SPY will be my only option.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 5:34 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Aren't you getting a load of lines like this?
Code:
DEBUG [org.hibernate.type.StringType] org.hibernate.type.NullableType NullableType.java:59 - binding 'DeleteMe!' to parameter: 2
DEBUG [org.hibernate.type.IntegerType] org.hibernate.type.NullableType NullableType.java:59 - binding '2' to parameter: 3
DEBUG [org.hibernate.type.DoubleType] org.hibernate.type.NullableType NullableType.java:59 - binding '0.0' to parameter: 4
DEBUG [org.hibernate.type.DoubleType] org.hibernate.type.NullableType NullableType.java:59 - binding '0.0' to parameter: 5
The ?s in the actual SQL lines are never replaced, that's how the strings are sent to the JDBC driver. These debug lines are the printouts for parameter bindings.


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