• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Springboot JPA SQL output

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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

 
Ranch Foreman
Posts: 1903
12
  • Mark post as helpful
  • send pies
  • 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: 22125
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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: 22125
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • 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.
 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic