1

I have migrated from Hibernate 4 to Hibernate 5.2.17 and use CriteriaQuery now as opposed to the old Criteria.

While debugging, we could do the following in Hibernate4 to see how the query looks like eventually

String sqlOutput = allStudents.unwrap(org.hibernate.Query.class).getQueryString();

logger.debug("see query {}",sqlOutput);

I am still able to use the above, but I keep getting a warning that Query.class and getQueryString is deprecated. What is the alternative in Hibernate 5. I have gone through the documentation - they mention that it is deprecated but no alternative is provided.

Alternatively, is there a way to print the criteria queries to console in JPQL or mysql format ?

HopeKing
  • 2,574
  • 3
  • 34
  • 54

0 Answers0