• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Springboot JPA SQL output

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

 I am developing spring boot app to get an entity  which has join of 3-4 tables.  I enabled sql output in application.properties . But i am seeing only high level SQL . Is there
any way i can print all join queries also when fetching the data :

---------------SQL output --------------------------

select
       parent0_.pk_pk_key as pk__p1_6_,
     from
       mainentity0_
   where
       mainentity0_.pk_emp_key in (
           ? , ? , ? , ? , ?
       )

---------------------------Tables -------------------------------------------------------------------------------------------------------


Thanks

 
Bartender
Posts: 2265
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You may want to use Logger to log the SQL queries. Here is an example https://stackoverflow.com/questions/30118683/how-to-log-sql-statements-in-spring-boot
 
Saloon Keeper
Posts: 26541
187
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using Hibernate JPA, there are a set of logging identifiers that can tell you more than you'll ever want to know about what Hibernate is doing, and yes, there's one that specifically prints out the generated SQL.

Other JPA facilities will generally have similar log options, but since Hibernate is probably the most popular JPA provider, I did want to be specific about it.
 
naresh babu
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you! for the inputs.  Springboot is able to log query output when retreiving 1 entity using .

But incase of using- its printing only main query . But its not logging mapped Entities SQL queries.

Please update if there is any other way i can get this info
 
Tim Holloway
Saloon Keeper
Posts: 26541
187
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm afraid I don't understand what you just said.

However, the Hibernate SQL log facility does print out the full text of every SQL statement it generates. Spring Boot has nothing to do with that. It works the same everywhere.
reply
    Bookmark Topic Watch Topic
  • New Topic