Spring Boot – Show Hibernate SQL query

Add the following lines in application.properties to log the Hibernate SQL query. application.properties #show sql statement logging.level.org.hibernate.SQL=debug #show sql values logging.level.org.hibernate.type.descriptor.sql=trace 1. org.hibernate.SQL=debug application.properties logging.level.org.hibernate.SQL=debug 1.1 Select query. Console 2017-02-23 21:36:42 DEBUG org.hibernate.SQL – select customer0_.id as id1_0_, customer0_.created_date as created_date2_0_, customer0_.email as email3_0_, customer0_.name as name4_0_ from customer customer0_ 2. org.hibernate.type.descriptor.sql=trace application.properties logging.level.org.hibernate.SQL=debug logging.level.org.hibernate.type.descriptor.sql=trace …

Read more

Display Hibernate SQL to console – show_sql , format_sql and use_sql_comments

Hibernate has build-in a function to enable the logging of all the generated SQL statements to the console. You can enable it by add a “show_sql” property in the Hibernate configuration file “hibernate.cfg.xml“. This function is good for basic troubleshooting, and to see what’s Hibernate is doing behind. 1. show_sql Enable the logging of all …

Read more

How to get random row from sql query – PostgreSQL

How can i get a random row from a query result in PostgreSQL? The answer is easy, just using RANDOM() built-in function in PostgreSQL SELECT scoreid FROM n_score ORDER BY RANDOM() limit 1; Above example will get a random score id from table n_score. Everytime execute it will get a random score id. Done.

Convert Subquery Result to Array

I want my subquery results (multi rows) return as a singale row in my query. For example. select u.url, (select c.categoryid from category c where c.categoryid = u.categoryid) from url u If url contains multiple categories, subquery will return multiple rows as following P.S Subquery return multiple rows is not supported in most of the …

Read more