How to debug JPA CriteriaBuilder requests

How can I debug a query built with JPA 2.0 CriteriaBuilder? Is there a way to print a query that is running?

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

+5
source share
1 answer

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

eg.

For Hibernate (used, for example, JBoss AS):

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

For EclipseLink (used, for example, GlassFish) this is:

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

.: SQL-, JPA?

+13

All Articles