Can I get the SQL string from a JPA Query object?

前端 未结 8 623
慢半拍i
慢半拍i 2021-01-01 12:36

May I know how can I get the sql from a JPA query? or let\'s say, convert the JPA query to a SQL string? Thank you very much!

8条回答
  •  抹茶落季
    2021-01-01 13:17

    If you only want to know how your JPQL or Criteria Query gets translated to the SQL dialect of your database you can enable fine grained logging in the persistence xml and then look into your log files.

    The property name and value depends on your JPA implementation. Here is an example of the relevant part of persistence.xml for EclipseLink:

    
        
    
    

提交回复
热议问题