开发者

createSQLQuery to HQL

First of all I am new to spring MVC and hibernate. My senior has told me that in our project they have used createSQLQuery to fire sql at many places, 开发者_StackOverflownow he wants me to make a detailed list, which all of them can be converted to HQL and which all not.

I did not used createSQLQuery or HQL before so how could I tell him which createSQLQuery can be converted to HQL and which not.


Basically, you need to learn Hibernate and HQL in order to answer this question.

From practice, the following kinds of SQL queries usually can't be converted to HQL:

  • Queries against tables or views not mapped by Hibernate
  • Queries with subqueries in SELECT and FROM clauses (if they can't be rewritten to equivalent form without these subqueries)
  • Queries with UNION, INTERSECT, EXCEPT.
  • Queries that use DBMS-specific features

Also note that HQL queries sometimes produce suboptimal SQL, so that some queries can be represented in hand-crafted SQL for performance reasons.

See also:

  • Chapter 16. HQL: The Hibernate Query Language
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜