命名查询在休眠中的优点? [英] Advantages of Named queries in hibernate?

查看:84
本文介绍了命名查询在休眠中的优点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用hibernate并希望使用命名查询。但我不知道这是否是好的解决方案?请为我提供命名查询的优势。



当命名查询编译完成时?
我们可以直接更改应用程序服务器中部署的hbm文件中的命名查询吗?



请帮助我。



谢谢!

解决方案

命名查询是在SessionFactory实例化时编译的(所以,基本上,当您的应用程序启动时)。 > advantage ,因此,当时所有命名查询都经过验证,而不是在执行后失败。另一个好处是它们很容易( - ier)维护 - 当然对于复杂的查询。



劣势是命名查询在运行时不可定制 - 当然,您可以定义/提供参数,但除此之外,您定义的是您将获得的内容;你甚至不能改变排序。另一个缺点是,无法在正在运行的应用程序服务器中更改命名查询,而无需重新加载SessionFactory


I am using hibernate and wanted to use named queries. but i dont know whether it is good solution or not? please provide me the advantages of named queries.

When named queries are compiled? can we directly change named query in hbm file which is deployed in application server?

Please help me.

Thanks!

解决方案

Named queries are compiled when SessionFactory is instantiated (so, essentially, when your application starts up).

The obvious advantage, therefore, is that all your named queries are validated at that time rather than failing upon execution. The other advantage is that they're easy(-ier) to maintain - certainly for complex queries.

The disadvantage is that named queries are not customizable at runtime - you can define / supply parameters, of course, but beyond that what you've defined is what you'll get; you can't even change the sorting. Another disadvantage is that you will not be able to change the named query within a running application server without reloading the SessionFactory.

这篇关于命名查询在休眠中的优点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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