Hellu,
I am using hibernate version 2.1.1.
I have all my HQL queries documented as named queries in the mapping files through the query tag.
I now have a native SQL query as Hibernate doesn't support subqueries in the FROM.
How is the best thing to deal with this such that I document it outside my source and use it in the source ?:
I quess I have to use session.createSqlQuery(String).
But is it correct to do it like this:
String queryStr = session.getNamedQuery(namedQuery.getName()).getQueryString();
Query qry = session.createSqlQuery(queryStr);
And then add my query parameters:
qry.setParameter("some name", "some value");
Please let me know if this is the correct way to do it, some best pratice advice ?
Regards,
Ed Bras
|