您是否会将 NHibernate 用于具有遗留数据库的项目,这在一定程度上是您无法控制的? [英] Would you use NHibernate for a project with a legacy database, which is partly out of your control?

查看:14
本文介绍了您是否会将 NHibernate 用于具有遗留数据库的项目,这在一定程度上是您无法控制的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对我来说,目前的答案是:不,我会使用 iBatis,因为当数据库模型和对象模型不同步时,NHibernate 是一种痛苦.如果我不能完全控制数据库,我最终会做很多工作.

For me the answer is currently: No, I would use iBatis, because NHibernate is a pain, when the database model and the object model are not in synch. If I don't have full control over the database I end up with a lot of work.

我为什么要问?

好吧,首先:我从未使用过 NHibernate.我只是从表面上知道.我已经阅读了 iBatis 对遗留数据库的优势.

Well, first of all: I never used NHibernate. I just know it from the surface. I have read about the advantages of iBatis for legacy databases.

第二:最近我和一个使用 Hibernate 的人进行了讨论(jep,在 Hibernate 之前没有'N').他告诉我,ORM 框架现在非常先进,并且提倡 Hibernate.由于我对 NHibernate 不感兴趣,所以我没有跟踪最近的发展.

Second: Recently I had a discussion with someone who worked with Hibernate (jep, without 'N' before Hibernate). He told me that the ORM frameworks are now pretty advanced and advocated Hibernate. Since I was not interested in NHibernate, I didn't keep track of the recent developments.

也许我是时候重新考虑我的答案了?

Maybe I its time to rethink my answer, or not?

推荐答案

iBatis 当然很容易将对象映射到遗留数据库系统.

iBatis is certainly easy to map objects to legacy database systems.

最近的 NHibernate 1.2 和 2.0 有一个特性集,可能会让你重新思考 iBatis.

More recently NHibernate 1.2 and 2.0 have a feature set that may make you rethink iBatis.

NHibernate 使用复合键,这在较旧的数据库中经常出现,使用它们并不总是令人愉快,但对此提供支持.

NHibernate works with composite keys, which can occur frequently in older databases, they aren't always pleasant to work with but support is there for this.

NHibernate 可以利用存储过程对实体和数据库视图进行 CRUD 操作.

NHibernate can utilise Stored Procedures for CRUD operations on entities, also database views.

集合可以是自定义存储过程或 SQL 查询.当外键关系没有直接映射到另一侧的主键时,集合可以使用 property-ref 属性.

Collections can be custom stored procedures or SQL queries. Collections can use the property-ref attribute when the Foreign Key relationship doesn't map directly to the Primary Key on the other side.

其中一些功能可能会削弱 nhibernate 的性能/功能,即使用 property-ref 进行延迟加载不起作用(根本不起作用?),但大多数情况下是有原因的.

Some of these features may take away from the performance/power of nhibernate, ie Lazy Loading with property-ref doesn't work (at all?), but is most cases there are reasons for this.

其他要点:(与您的旧数据库并不真正相关,但仍可帮助您决定技术选择)

Other points: (which aren't really related to your legacy database but still can help decide on a technology choice)

Nhibernate 社区看起来比 iBatis 丰富得多.我在这两个列表中,与 iBatis 组相比,对 NHibernate 的支持量相当大.所以支持应该更容易.

The Nhibernate community appears much richer than the iBatis. I'm on both lists and the volume of support for NHibernate is quite large compared to the iBatis group. So support should be easier.

还有越来越多的用于 NHibernate 的 contrib/3rd 方工具.诸如 NHibernate Profiler、Nhibernate 查询分析器、NHibernate Contrib、Fluent NHibernate 之类的东西.

Also there is a growing amount of contrib/3rd party tools for NHibernate. Things like The NHibernate Profiler, the Nhibernate Query Analyzer, NHibernate Contrib, Fluent NHibernate to name a few.

也许您可以扩展您认为 iBatis 目前拥有的优势.NHibernate 最近确实非常活跃,并获得了许多新功能,其中很多确实有助于遗留/难以修改的模式.

Perhaps you can expand on what advantages you believe iBatis currently has. NHibernate has certainly been quite active recently and has gained many new features, a lot of which do assist in legacy/hard to modify schemas.

为了回答这个问题,是的,我们确实将 NHibernate 与具有糟糕关系、复合键、断开关系的旧数据库一起使用.我们还有少量基于 iBatis 的代码.不过,我们不再编写任何 iBatis 代码.

And to answer the question, yes we do use NHibernate with legacy databases that have awful relationships, composite keys, broken relationships. We still also have a small amount of code based on iBatis. We no longer write any more iBatis code though.

这篇关于您是否会将 NHibernate 用于具有遗留数据库的项目,这在一定程度上是您无法控制的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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