Does anyone know how to convert NHibernate HQL to SQL Scripts?
相关问题
- Hibernate and multiThread Logic
-
NHibernate Query
with detached criteria… - Fluent NHibernate automap PostGIS geometry type
- Using NHibernate to execute DDL statements
- Setting Linq to NHibernate ADO Command Timeout
相关文章
- Fluent NHibernate — Saving Entity with Composite K
- Is this the right way of using ThenFetch() to load
- Can Persistence Ignorance Scale?
- How to left join unrelated entities?
- How to find if a referenced object can be deleted?
- NHibernate SQL query slow
- NHibernate: How to perform eager subselect fetchin
- Nhibernate Conformist Mapping “Unable to determine
I'm not familiar with all the parameters, but this seems to work:
With NHibernate 3.2, this seems to be the easiest way to get the SQL from an HQL query:
My old trainings. That was beta-version. Here it is! (hql2sql.jsp)
Here is how to do it with NH 5.2 (see https://stackoverflow.com/a/55542462/2047306)
Since HQL translation depends on your mappings and also runtime behaviour, I think it is unlikely there is a way to do so statically.
You could run the HQL against a real database and capture the generated SQL either via a profiler for your specific rdbms or NHProf.
I'm not sure what the value of auto-converting HQL to SQL is dynamically...
What exactly are you trying to accomplish by this?
The easiest way would be to run your code while running SQL Server Profiler to see the generated SQL. But a better approach would be to download nhProf (www.nhprof.com) and use that with your code. You will be able to see exactly what your code is outputting in SQL and it will format and color code it and also give you tips on ways to improve your usage of nhibernate.