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-- Lgging SQL query and binding parameters in single statement

 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Can I log SQL statements (select, insert, update, delete) and binding parameters in one single statement?

If yes can you please let me know how?(Interceptors and classes that I may need to use?)

Please let me know if you need more information.
 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any pointers/suggestions on this?
 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any suggestions?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't think of a way to do this. But its pretty easy to output the SQL followed by the parameter values - use hibernate.show_sql and have org.hibernate.types log at debug. Or you could use p6spy.
 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,
I am doing what you mentioned and I can see the sql and binding parameters in my logs but what I am trying to accomplish is get the sql query dynamically and execute the "EXPLAIN PLAN" on it through my test cases. Something like below

satement.execute("EXPLAIN PLAN FOR XXXXXX");


where XXXXXX is the sql query from hibernate
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic