• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing hibernate generated SQL

 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I want to get sql query generated by hibernate in one string object.
dose any one know how do it ?

For more information;the query that is printed on console when show_sql is set to true in cfg file.


Cheers
-Praful
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could just redirect standard output I suppose ( e.g. System.setOut(PtintStream out) ). I'm not sure why you might want to though.
 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

Many Thanks for your reply. I want to log all the queries into a log file;any idea how can I do that?


Warm Regards
-Praful
 
Loren Rosen
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IIRC Hibernate uses Log4j. You should be able to configure log4j to send different messages to different log files.

Alternatively, you could post process the log file to extract just the messages you're interested it. This shouldn't be too hard with the usual Unix tools like grep, sed, awk, etc., or perl if necessary. I'm less familiar with simple text processing on Windows but something must be available.
 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a bunch Loren.

Will try that option..

-Praful
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic