Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Why can't Hibernate print SQL statements with parameters?
PostPosted: Thu Oct 05, 2017 3:12 pm 
Newbie

Joined: Wed Feb 22, 2017 4:35 pm
Posts: 17
I'm aware there's a way to do this (which I am struggling to set up), but even if I get that to work, hibernate will print each parameter in its own line with bind parameter yada yada. Why can't hibernate simply print out the string that it is sending directly to the database?


Top
 Profile  
 
 Post subject: Re: Why can't hibernate print SQL statements with parameters?
PostPosted: Fri Oct 06, 2017 3:03 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1422
As I explained in this article, Hibernate can do that just fine.

You only have to add a TRACE logger for org.hibernate.type.descriptor.sql package.

However, if you want to do it like a pro, then you should use datasource-proxy or p6spy. This way, you can even detect N+1 query issues automatically. Cool, right?

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: Why can't Hibernate print SQL statements with parameters?
PostPosted: Fri Oct 06, 2017 1:29 pm 
Newbie

Joined: Wed Feb 22, 2017 4:35 pm
Posts: 17
Thanks, that gives me something to chew on for sure.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

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.