性能createNamedNativeQuerie vs createNativeQuery [英] Performance createNamedNativeQuerie vs createNativeQuery

查看:145
本文介绍了性能createNamedNativeQuerie vs createNativeQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

createNamedNativeQuerie createNativeQuery 之间有任何与性能相关的功能。因为我们打算为HQL查询使用命名查询,并为原生SQL查询维护单独的查询文件。 解析方案

命名的本机查询:此查询的范围是持久性上下文&可以通过指定其标识符在应用程序中使用。该查询不能随后更改,即静态。
它们仅在服务器启动时验证一次(特定于JBoss)

原生查询:一种纯粹的原生sql查询。可以在运行时建立动态查询&执行它。在每次执行查询时,它们都将被验证。



在具有普通数据库操作的小应用程序中,差异可能不明显,但在具有众多数据库调用的企业应用程序中,有效。

命名原生查询的性能比原生查询的性能要好。


is there any performance related features between createNamedNativeQuerie and createNativeQuery. because we are planning to use named query for HQL query's and maintain separate query file for native SQL query's

解决方案

Named Native Query : The scope of this query is persistence context & can be used in the application by specifying its identifier. The query can't be changed afterwards, its static. They are validated only once, at the server startup(JBoss specific)

Native Query : A plain native sql query. Can build dynamic query at runtime & execute it. They will be validated each time the query is executed.

In small applications with normal database operations, difference might not be notable, but in enterprise applications with numerous database calls, will have an effect.

Performance of named native queries is better than that of native queries.

这篇关于性能createNamedNativeQuerie vs createNativeQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆