开发者

Named Queries Pros and Cons

Is there any significant advantage of having queries as Nam开发者_JAVA技巧edQueries over the Entities? If not we could have it in the DAO itself. Kindly throw some ideas in this regard.


Named queries provide a significant performance benefit, when the application requires repeated execution of the same query. The key concept to this is that every query, no matter what syntax you use to write them in your business tier (hibernate syntax for example), will end up (must end up) as a native query (i.e. a syntax that your database understands) in order to be executed. This tranformation is called compilation and is considered a time comsuming process. So the performance benefit comes from the fact that Named Queries are compiled to their native syntax once by hibernate and execute ever after, whereas dynamicaly created queries must be compiled every time to their native syntax, before their execution.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜