This page may help: https://antoniogoncalves.org/2012/05/24/how-to-get-the-jpqlsql-string-from-a-criteriaquery-in-jpa/
But we still need a JPA-vendor-neutral way which implements toString() in org.hibernate.jpa.ciretia.CriteriaQueryImpl