您是否将NHibernate用于具有遗留数据库的项目,而遗留数据库是部分无法控制的? [英] Would you use NHibernate for a project with a legacy database, which is partly out of your control?

查看:125
本文介绍了您是否将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 party工具也越来越多.诸如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天全站免登陆