Hibernate与iBATIS [英] Hibernate Vs iBATIS

查看:106
本文介绍了Hibernate与iBATIS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我们的新产品重新设计,我们正在从Java中选择最佳框架。考虑到模型的数据库不可知方法,我们正在研究Struts + Spring与iBATIS或Hibernate之间的选项。请提供最好的建议,因为这两者都提供持久性。

解决方案

我倾向于这样看待:如果您的视图更多以为中心,则Hibernate会更好地工作。如果你认为更多是以数据库为中心的话,那么Ibatis是一个更强大的选择。如果你完全控制了你的模式并且你没有一个非常高的吞吐量要求,然后Hibernate可以很好地工作。对象模型使代码变得相当方便,但复杂度很高。



如果你正在处理一个遗留数据库模式,其中您需要编写相当复杂的SQL查询,然后Ibatis可能会更好地工作。


$ b HQL(Hibernate查询语言)是您必须学习的另一种语言,您甚至可以您可能会发现您仍然需要编写SQL的情况。更重要的是,你可能会花半天时间弄清楚XML,属性,注释等的正确组合,让Hibernate生成一个高性能的SQL查询。



对于这个问题,没有普遍的A比B好的答案。


For our new product re-engineering, we are in the process of selecting the best framework from Java. As the consideration is to go for database agnostic approach for model, we are working on options between Struts + Spring with iBATIS or Hibernate. Please advice which is best as both offer persistence.

解决方案

Ibatis and Hibernate are quite different beasts.

The way I tend to look at it is this: Hibernate works better if your view is more object-centric. If however you view is more database-centric then Ibatis is a much stronger choice.

If you're in complete control of your schema and you don't have an extremely high throughput requirement then Hibernate can work quite well. The object model makes for fairly convenient code but at a huge complexity cost.

If you're dealing with a "legacy" database schema where you need to write fairly complicated SQL queries then chances are Ibatis will work better.

HQL (Hibernate Query Language) is another language you'll have to learn and even then you'll probably find cases where you still need to write SQL. What's more, chances are you will at some spend half a day figuring out the right combination of XML, properties, annotations, etc to get Hibernate to generate a performant SQL query.

There is no universal "A is better than B" answer for this question.

这篇关于Hibernate与iBATIS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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