How to debug JPA CriteriaBuilder queries

13,900

Solution 1

The same attributes in persistence.xml that also print the SQL that is generated from regular JPQL queries, should also print the SQL that is generated from Criteria queries.

E.g.

For Hibernate (used by e.g. JBoss AS) it's:

<property name="hibernate.show_sql" value="true" />

For EclipseLink (used by e.g. GlassFish) it's:

<property name="eclipselink.logging.level" value="FINE"/>
<property name="eclipselink.logging.parameters" value="true"/>

Also see: How to view the SQL queries issued by JPA?

Solution 2

if you are using java spring , under resources, in application.properties file add the below line

spring.jpa.show-sql=true
Share:
13,900
perissf
Author by

perissf

Passionate about finance (trading, modeling, risk management), Java programming and hiking

Updated on June 04, 2022

Comments

  • perissf
    perissf almost 2 years

    How can I debug a query built with JPA 2.0 CriteriaBuilder? Is there a way to print out the query that is being executed?

    I am developing a web application using NetBeans, MySql, GlassFish. I would avoid starting MySql in debug mode, because it is used also for other applications. JPA provider is EclipseLink.