• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Hibernate SQL

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am very much new to hibernate and please do excuse me if this question sounds very generic and have been asked million times. I would appreciate if you could help me understand or point to an old topic related to it. Thanks in advance.

I am writing a sample hibernate query and want to display the sql in my printf statement.

Q. How do I determine what SQL Hibernate is generating?

Appreciate your help.

Regards,
Sachin
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sachin,

you should have a file named hibernate.cfg.xml somewhere. In this file there is a tag <properties>. You can add these three to the properties:



I suppose you have these lines already in your hibernate.cfg.xml and just have to remove the comment ("<!-- SQL stdout logging") markers.
(in my example I would have to remove them, too).


John
 
Sachin Deokar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks John for your reply.

Your suggestion works really good for me, i removed the comments for those lines and now i can see the sql in the console.

I also found a suggestion for using org.hibernate.Interceptor.onPrepareStatement(). Haven't tried that yet, but i think it will help me write individual sql's in the console.

Regards,
Sachin
 
John Bengler
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The org.hibernate.Interceptor.onPrepareStatement() sounds interesting. Thanks for sharing!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic