NHibernate 和 iBATIS.NET 有什么区别?

发布于 2024-07-16 05:00:16 字数 525 浏览 4 评论 0原文

我正在寻找一些比较 NHibernate 和 iBATIS.NET 的最新信息。 我在 Google 上搜索到了一些信息,但其中很大一部分要么适用于这些产品的 Java 版本,要么已经过时了。

我感兴趣的一些具体事情:

  • 如果同时控制数据模型和应用程序,哪个更好?
  • iBATIS 被反复称为更容易学习 - 这是否会带来长期的维护后果(即易于启动,难以维护)?
  • 两者都可以轻松切换底层数据库供应商吗?
  • 您的开发人员需要掌握多少 SQL 技能?
  • 有什么主要特征是一个人拥有而另一个人缺乏的吗?
  • 任一产品是否更适合特定类型的应用?

观察到的优点和缺点的真实例子值得赞赏!

编辑:感谢您提供的信息。 我也在做我自己的评价。 我仍然想知道一件事,iBATIS 是否可以帮助您保存/更新复杂的对象图? NHibernate 似乎很好,因为我可以向它传递一个根对象,它会计算出数据库中需要更新的内容(如果有的话)的详细信息。

I am looking for some up to date information comparing NHibernate and iBATIS.NET. I found some information searching Google, but a good bit of it applies either to the Java versions of these products or is dated.

Some specific things I am interested in:

  • Which is better if you control both the data model and the application?
  • iBATIS is repeatedly called simpler to learn - does this have long-term maintenance consequences (i.e. easy to start, hard to maintain)?
  • Do both make it easy to switch the underlying database vendor?
  • How skilled do your developers need to be with SQL?
  • Any major feature that one has that the other lacks?
  • Is either product more suitable for a particular type of application?

Real world examples of observed benefits and drawbacks are appreciated!

EDIT: Thanks for the information. I am doing my own evaluation as well. One thing I am wondering about still, does iBATIS help you to save/update complex object graphs? It seems like NHibernate is nice in that I can pass it a root object and it figures out the details of what, if anything, needs to be updated in the database.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

灯下孤影 2024-07-23 05:00:16

我不久前做了一些研究。

我提出的一个具体问题可能会给您一些额外的信息:
你愿意吗将NHibernate用于具有遗留数据库的项目,这部分超出了您的控制范围?

您的一些兴趣点我可以回答:

  • 如果您同时控制数据模型和应用程序,哪个更好?

我可以反过来回答:如果您无法控制数据模型并因此面对一些遗留数据库,iBatis 是更好的选择。

  • iBATIS 被反复称为更容易学习 - 这是否会带来长期的维护后果(即易于启动,难以维护)?

这取决于您想用它做什么。 如果您采用领域驱动的开发方法,那么随着时间的推移,iBatis 可能会变得痛苦。 如果您只是进行简单的数据操作,并且没有完整的域模型,那么 nHibernate 可能就有点大材小用了。

  • 两者都可以轻松切换底层数据库供应商吗?

两者都有机制来保护您免受特定数据库供应商的影响,但我承认还没有在这个方向上进行深入的研究。

  • 您的开发人员需要掌握多少 SQL 技能?

当你使用 iBatis 时,你需要比 NHibernate 更多的 SQL 技能。 使用 iBatis,您总是需要编写一些 SQL 代码。 NHibernate 不需要您编写 SQL 语句——它甚至可以为您执行 DDL。 强大的功能将要求您使用旧的好的 SQL,这是不可避免的。

其他一些要点:

  • 我个人发现 iBatis 更加轻量级。 你可以很快地完成事情。 NHibernate 更强大,但有更多的功能,您可能会以错误的方式使用这些功能。

  • 可以结合使用 NHibernate 和 iBatis! 您可以将 NHibernate 用于您的业务逻辑。 出于报告目的,您只需从表中读取数据,然后回退到 iBatis。

  • 如果您的应用程序有较长的生命周期和大量的业务逻辑,请考虑 NHibernate。 它有很多功能可以帮助您处理业务对象。

  • NHibernate 周围的社区非常活跃,并且提供了有用的工具。

I made some research a while ago.

One specific question from me, might give you some additional information:
Would you use NHibernate for a project with a legacy database, which is partly out of your control?

Some of your points of interest I can answer:

  • Which is better if you control both the data model and the application?

I can answer it the other way around: If you don't have control over the data model and thus facing some legacy database, iBatis is the better choice.

  • iBATIS is repeatedly called simpler to learn - does this have long-term maintenance consequences (i.e. easy to start, hard to maintain)?

It depends what you want to do with it. If you have a domain driven development approach then iBatis might get painful by time. If you just do simple data manipulation and don't have a full blown domain model then nHibernate might be a overkill by the time.

  • Do both make it easy to switch the underlying database vendor?

Both have mechanisms to shield you off from a specific database vendor, but I admit that have not done intense research in this direction.

  • How skilled do your developers need to be with SQL?

When you use iBatis, you need more SQL skills than NHibernate. Using iBatis you always need to code some SQL. NHibernate doesn't require you to code SQL statements -- it even can do the DDLs for you. Powerful features will require you to go to old good SQL, which will be inevitable.

Some other points:

  • I personally find that iBatis much more lightweighter. You can get things done very quickly. NHibernate is more powerful, but has much more features, which you can use in wrong way.

  • It is possible to combine the use of NHibernate and iBatis! You can use NHibernate for your business logic. For reporting purposes, where you just read data out of tables, fallback to iBatis.

  • If your application has a longer life cycle and a lot of business logic, consider NHibernate. It has a lot of feature aiding you in handle business objects.

  • The community around NHibernate is very active and come up with useful tools.

雅心素梦 2024-07-23 05:00:16

从某种意义上说,这是在将苹果与橙子进行比较。

如果同时控制数据模型和应用程序,哪个更好?

它们都可以很好地处理标准化数据库,因此如果您可以塑造数据库,它们或多或少是相等的。 iBatis 更擅长映射到遗留数据库,因为它实际上根本不关心数据库结构。 它只关心结果集的形状。

.iBATIS 被反复称为更容易学习 - 这是否会产生长期维护后果(即易于启动,难以维护)?

它要简单得多,但那是因为它的功能集要小得多。 我不认为它有任何定时炸弹的长期维护问题。

两者都可以轻松切换底层数据库供应商吗?

是的

您的开发人员需要掌握多少 SQL 技能?

两者都需要对 SQL 有很好的了解。 使用 iBatis,您仍然需要编写 sql 查询/过程。 使用 NHibernate,您必须知道如何编写 NHibernate 查询以获得有效的 SQL。 两者都不能替代 SQL 知识。

有哪些主要功能是一个人拥有而另一个人缺乏的?

iBatis 是一个数据映射器(iBatis 站点上使用的术语)。 NHibernate 是一个成熟的对象关系映射器。 如果您主要想要摆脱将对象映射到结果集的单调乏味,那么 iBatis 是一个很好的选择。 然而,它并没有完全解决对象/关系不匹配的问题。 NHibernate 具有更多功能,例如脏跟踪、基于身份/身份映射的缓存、灵活查询、动态 sql、批处理等... NHibernate 更加动态,因为它可以在数据库的一次访问中完成许多事情,这些事情可能需要iBatis 好几趟了。

In a sense it's comparing apples to oranges.

Which is better if you control both the data model and the application?

They both work with normalized databases well, so they are more-or-less equal if you can shape the db. iBatis is better at mapping to legacy databases since it doesn't actually care about the database structure at all. It only cares about the shape of the result set.

.iBATIS is repeatedly called simpler to learn - does this have long-term maintenance consequences (i.e. easy to start, hard to maintain)?

It is much simpler, but that is because it has a much smaller featureset. I don't think it has any ticking timebomb long term maintenance issues.

Do both make it easy to switch the underlying database vendor?

Yes

How skilled do your developers need to be with SQL?

Both require a good knowledge of SQL. With iBatis, you still have to write the sql queries/procs. With NHibernate you have to know how to write NHibernate queries to get effective SQL. Neither are a replacement for SQL knowledge.

Any major feature that one has that the other lacks?

iBatis is a datamapper (a term used on the iBatis site). NHibernate is a full-blown Object Relational Mapper. iBatis is a great way to go if you primarily want something that takes the monotony out of mapping objects to result sets. However, it doesn't go all the way in trying to solve the object/relational mismatch. NHibernate has many more features such as dirty tracking, caching based on identity /identity map, flexible querying, dynamic sql, batching etc... NHibernate is much more dynamic in that it can do many things in one trip to the DB that could take iBatis several trips.

泪意 2024-07-23 05:00:16

我们最近发布了一篇文章比较这两种工具,我认为您的许多问题都得到了解决。 该文章位于我们的 wiki 网站

We recently posted an article comparing these two tools, and I think many of your questions are addressed. The article is here on our wiki site.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文