Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

show query  RSS feed

 
Nikhil Jain
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way in JPA to output the actual executed query. I think this was possible with Hibernate.

For eg if I execute query EntityManager.createQuery("SELECT E FROM EMPLOYEE E");

Can I use some API to print its actual query like
select * from employee;

I did not find any such thing in JPA
 
Scott Selikoff
author
Bartender
Posts: 4093
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a debug version of the JDBC driver and turn on debugging output. Even JPA with its pseudo-queries still has to translate it to an underlying JDBC driver. Alternatively, turn on tracing on the server and you can monitor what queries are sent to it.
[ July 10, 2008: Message edited by: Scott Selikoff ]
 
Marko Novakovic
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use Hibernate as JPA provider you can use property show_sql and it will print it in console in PreparedStatement format (with those ?)

Maybe other providers have similar feature.
 
peter tong
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I feel interest on the "property show_sql "..., how to write it in code?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!