Loss of getQueryString() method moving from v5 to v6

Moving from Spring Boot 2 to Spring Boot 3 forces a move from Hibernate 5 to Hibernate 6.

We have an application that uses a dynamically constructed CriteriaQuery to display data in a UI, but then to allow download of the data we make use of PostgreSQL UNLOAD command to send the data to an AWS S3 bucket. The generation of the UNLOAD commands requires the translation of the CriteraQuery to String representing the corresponding SQL SELECT statement.

The translation is currently being done with the getQueryMethod() after unwrapping the TypedQuery. A direct replacement seems to be missing, does anyone know how this might be accomplished within Hibernate 6?

This is not so easy. A CriteriaQuery or HQL query could be split into multiple separate queries (polymorphic query). The final SQL might depend on parameter values when e.g. parameters are used in a context that doesn’t allow untyped expressions and the parameter type is unknown.
So if you want to get your hands on the SQL with ORM 6, you will have to do what ORM 6 does internally and translate the query. Take a look into org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan which is the entry point for that whole translation process. You need to get your hands onto a JdbcOperationQuerySelect which has a getSqlString() method.