是否有一个很好的理由来使用XML,而不是通过注释配置Hibernate? [英] Is there a good reason to configure hibernate with XML rather than via annotations?

查看:73
本文介绍了是否有一个很好的理由来使用XML,而不是通过注释配置Hibernate?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用休眠了数年,但只用注释使用它,并在我的code设置连接参数。

I've been using Hibernate for a few years but have only used it with annotations, and by setting the connection parameters in my code.

我是不是缺少的东西,不使用XML文件?是否有重要能力仅适用于XML?是否有情况或在有意义使用XML模式?

Am I "missing something" by not using the XML files? Are there important capabilities available only in XML? Are there situations or patterns where it makes sense to use the XML?

推荐答案

我认为这是pretty安全地说,你没有任何东西错过了。

I think it's pretty safe to say that you're not missing out on anything.

如果有在XML的功能,不能重新在属性psented(我相信有一些罕见的情况下)$ P $,那么你仍然有属性使用[RawXml]和编写XML选项。所以,你不可能错过任何功能。

If there are any capabilities in XML that can't be represented in attributes (and I believe there are some rare cases) then you still have the option to use [RawXml] and write the XML in the attribute. So you can't possibly miss out on any functionality.

这可能是有意义的使用XML,如果你有足够的程序员在你的团队谁只是preFER管理单独的文件,或者是否有真正需要的飞行编辑XML映射。 XML映射文件可能更容易操作非常复杂的映射,它们可以包含有用的信息(上抓取策略等评论)

It might make sense to use XML if you have enough programmers in your team who simply prefer to manage separate files or if there is a genuine need to edit xml mappings on the fly. Xml mapping files are probably easier to manipulate for very complex mapping and they can contain useful information (comments on fetching strategies etc).

还有建筑,其中一些人认为,分离映射到XML文件提供了关于它是如何坚持与业务相关的code和指令之间更好地分离的问题。

There is also the issue of architecture, where some people argue that separating the mapping into XML files provides a better separation between business-related code and instructions on how it is persisted.

这篇关于是否有一个很好的理由来使用XML,而不是通过注释配置Hibernate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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