1

we can print the generated sql query from hibernate on console.

Is there any way to get the that query in java code ?

Krish
  • 1,804
  • 7
  • 37
  • 65
  • you must be talking about generated SQL query from hibernate and not the hibernate query itself. – Acewin Mar 29 '18 at 16:37
  • sorry. I have updated the question – Krish Mar 29 '18 at 16:39
  • Possible duplicate of [How to get the JPA generated SQL query?](https://stackoverflow.com/questions/14358934/how-to-get-the-jpa-generated-sql-query) – Acewin Mar 29 '18 at 16:39
  • I have not tried this, but you can look into JPA Criteria API https://antoniogoncalves.org/2012/05/24/how-to-get-the-jpqlsql-string-from-a-criteriaquery-in-jpa/ – Acewin Mar 29 '18 at 16:46
  • @Acewin its giving only the JPQL. Also tried with EclipseLink but its giving error. – Krish Mar 29 '18 at 17:58
  • The JPQL getting printed is actually a SQL query. – Acewin Jan 10 '19 at 23:09

0 Answers0