-->
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.  [ 20 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: Mon Oct 16, 2006 5:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the problem is that some of this might not be part of an api we would like to expose in a public extension point.

still I would consider looking at a patch that provides such an extension point just to know how much/little we need to disclose - so feel free to look into it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Now working with Spring.
PostPosted: Mon Oct 30, 2006 4:46 am 
Beginner
Beginner

Joined: Mon Nov 22, 2004 11:21 am
Posts: 42
Hello Gavin,

you can make the code working with Spring if you cast the SessionFactory to the interface SessionFactoryImplementor instead of SessionFactoryImpl. (Casting to an interface is slightly better in terms of stability).

Can you please post your latest version of your code that handles NativeSQL as well?

Thanks in advance,
Georg

_________________
Real programmers confuse Halloween and Christmas because OCT 31 = DEC 25


Top
 Profile  
 
 Post subject: Found solution that works with Spring.
PostPosted: Tue Dec 12, 2006 3:09 pm 
Newbie

Joined: Tue Dec 12, 2006 3:00 pm
Posts: 1
Hi,

Having the same issue integrating the previously posted code with Spring, the bind parameters simply would not appear in the logs.

After a lot of searching I stumbled across this article:

http://java.sys-con.com/read/204723.htm

Which describes a small package that wraps your JDBC connection and traces out the query and parameters at the debug level.
Here is an example of the output:
Code:
[http-8180-3] DEBUG net.rkbloom.logdriver.LogPreparedStatement - executing PreparedStatement: '
    select
        volume1_.id as col_0_0_,
        volume1_.DESCR as col_1_0_,
        volume1_.CODE as col_2_0_
    from
        O_OA.DEPT_VOLUME deptvolume0_
    inner join
        O_OA.VOLUME volume1_
            on deptvolume0_.VOLUME_ID=volume1_.id
    where
        volume1_.FACILITY_ID=?
        and deptvolume0_.DEPT_ID=?
    order by
        volume1_.CODE' with bind parameters: {1=2512, 2=-1}


By default it will print the code on one line, but a small change to call the Formatter class in hibernate will return the formatting above.

Good luck and thanks for helping my along my search.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 15, 2007 2:10 am 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
You can also do this using Proxool.

Just configure Proxool as your JDBC driver (the same way you do for P6Spy) then switch on statement tracing(*) .

It actually works even better for me than P6Spy because:
* It's not a dead project like P6Spy
* It uses the default Log4J hierarchy and configuration mechanisms (P6Spy is usually awkward to integrate with the rest of your logging strategy)

It might not be as good as P6Spy for your own situation though because I'm not sure how well Proxool operates as a datasource inside an application server. But I only need it during my development testing, so it works well for me.


(*) I found configuring Hibernate with Proxool to be astonishingly painful (I found the same thing when I was using it with Hibernate a couple of years ago too - so no progress there). It's kind of cool once you get it working, but getting it to that point hurts (not just telling hibernate to use proxool and then telling proxool about my JDBC driver, but also being able to configure statement tracing to actually be switched on).

I found this page very helpful: http://hibernate.org/222.html

_________________
Cheers,
Shorn.


Top
 Profile  
 
 Post subject: Re: Logging SQL WITH named parameters and bind values
PostPosted: Mon Mar 22, 2010 2:53 pm 
Newbie

Joined: Mon Mar 22, 2010 2:39 pm
Posts: 1
Hello,

Someone mentioned posting the QueryLogger class on the wiki. Can someone please post a link to the wiki article?

Thank you.

PS: I'm trying figure out how to use the QueryLogger class. I'm new to hibernate. I am saving an object by calling hibernateTemplate.save(<someObject>). I just wan to the SQL that is being executed on the database in a regular SQL format with the values in place so that I can copy them and create an import.sql script.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 20 posts ]  Go to page Previous  1, 2

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.