Created
August 6, 2021 13:43
-
-
Save Chuckame/5638fc1109c601acb6eaa9c2640f7c59 to your computer and use it in GitHub Desktop.
Converts an HQL to SQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String toSQL(EntityManager em, String hql) { | |
SessionImplementor hibernateSession = em.unwrap(SessionImplementor.class); | |
HQLQueryPlan p = new HQLQueryPlan(hql, false, Map.of(), hibernateSession.getSessionFactory()); | |
if (p.getTranslators().length > 1) { | |
throw new UnsupportedOperationException(); | |
} | |
return p.getTranslators()[0].getSQLString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment