Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate SQL

 
Sachin Deokar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • 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
 
John Bengler
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
The org.hibernate.Interceptor.onPrepareStatement() sounds interesting. Thanks for sharing!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic