io.hypersistence.utils.hibernate.query.SQLExtractor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hypersistence-utils-hibernate-60 Show documentation
Show all versions of hypersistence-utils-hibernate-60 Show documentation
Utilities for Spring and Hibernate ORM 6.0 or newer
package io.hypersistence.utils.hibernate.query;
import io.hypersistence.utils.hibernate.util.ReflectionUtils;
import jakarta.persistence.Query;
/**
* The {@link SQLExtractor} allows you to extract the
* underlying SQL query generated by a JPQL or JPA Criteria API query.
*
* For more details about how to use it, check out this article on vladmihalcea.com.
*
* @author Vlad Mihalcea
* @since 2.9.11
*/
public class SQLExtractor {
protected SQLExtractor() {
}
/**
* Get the underlying SQL generated by the provided JPA query.
*
* @param query JPA query
* @return the underlying SQL generated by the provided JPA query
*/
public static String from(Query query) {
return ReflectionUtils.invokeMethod(query, "getQueryString");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy