spring framework show sql parameters

See the binding parameters in JPA query – java logs

see binding parameters in jpa query

What would the world look like if log was not created for us – I ask, and you say nothing! You right, there is also another world :)

Getting back from the crazy thoughts, there is a config spring allows us to see the SQL statements that the JPA is doing behind the scenes..

In you application.yml file

...
spring.jpa.show-sql=true
...

Will show the sql statements on your logs. But it will show with ? for the values used.

To see those values also along with the query add the following on the application file.


logging.level.org.hibernate.SQL=debug
logging.level.org.hibernate.type.descriptor.sql=trace

That is it!

PDO not throwing any exceptions

If you want pdo to thow exception so that you can see what is going on kinda thing.. you can add the following parameter when you instantiate PDO just next to the password part of the pdo

array(PDO::ATTR_EMULATE_PREPARES => false, 
                                                                                                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)

**Note: This is not the best way to handle exception by any means!!