Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Architecture & Framework  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 hibernate or ibatis?
sanshaoye





发贴: 16
积分: 0
于 2005-03-03 01:52 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我们有一个项目,对于dao层使用hibernate 还是 ibatis一直达不成一致。这个项目主要有这么几个特点:
1、需要与现有的系统相结合,如用户信息,可能要另一个数据库读取。
2、需要支持多种数据库。主要是主流的数据库,mysql,oracle,mssql等,当然是越多越好。
3、系统需要不断的升级。分几个阶段完成,并且两次升级过程中系统需要稳定运行。
4、系统相对更多的是查询操作,单表的数据量最大在百万级。

几点想法:
1、对于与原有系统相结合的问题,好像需要选ibatis
2、要支持多种数据库,用hibernate似乎更好
3、对于需要不断升级的系统,感觉选ibatis好一些

系统各位大虾给点建议,并说出选择的理由和问题的解决办法。



Nothing is impossible to a willing heart!
作者 Re:hibernate or ibatis? [Re:sanshaoye]
spi_cn





发贴: 194
积分: 32
于 2005-03-03 11:02 user profilesend a private message to usersend email to spi_cnsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
个人感觉iBatis强在复杂的查询和存储过程的使用,而Hibernate则在单表的操作上有优势,其实也可以在dao层使用hibernate+iBatis。


作者 Re:hibernate or ibatis? [Re:sanshaoye]
sanshaoye





发贴: 16
积分: 0
于 2005-03-03 13:41 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
hibernate3已经支持存储过程了,并且spring1.2就要加入hb3了
对于复杂的查询hb的criteria也很强的

个人感觉ibatis相对较容易掌握,但工作量要大很多,对于多数据库的支持有点不知道如何下手(偶经验不够呀),而hb只要配置一下就可以了,用HQL进行查询,不需要考虑不同数据库的问题。

但ibatis似乎更灵活,如果使用hb,对于升级时,一些表的字段需要添加之类的,会不会带来麻烦。

另外,使用hb似乎对于系统中一些对象的设计要求会更好,也就是需要更多的OOD,不知道对不对。而ibatis你数据库和对象设计的差一些,似乎也不会出什么问题。

真是难以决定 Sad



Nothing is impossible to a willing heart!
作者 Re:hibernate or ibatis? [Re:sanshaoye]
sanshaoye





发贴: 16
积分: 0
于 2005-03-06 18:09 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我们决定用ibatis


Nothing is impossible to a willing heart!
作者 Re:hibernate or ibatis? [Re:sanshaoye]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2005-03-07 11:09 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
ibatis is a SQL mapper, or an OR(object relational mapping), while hibernate is an ORM(object relational mapping manager). This one more M has a lot of implications on the mapping. There are some good references on the net on ORM. So you need to check whether you need those ORM features(for example, do you need to map a class inheritance hirachy into db?). If the answer is no or don't know, then pick ibatis, which is simpler.

I use ibatis because I have to use stored procs and hb2 doesn't support that. While hb3 starts supporting that, this concern is out.

I went the java conference in las vegas for 3 days, just came back, so couldn't answer soon.

iBATIS is a good choice. "You've got the right one, baby" - from Pepsi ad. Besides, a well designed DAO can switch implementations undetectably, well, largely.



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:hibernate or ibatis? [Re:sanshaoye]
skyin

A maverick piggy



发贴: 25
积分: 0
于 2005-05-01 10:36 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我记得以前TSS上有篇很热的帖子讨论数据库的。一派人认为应用程序应该是database independant,反对SP,应为那个不够OO.另一派认为更换数据库是不现实的,所以应该充分利用不同数据库各自的优化特性。

仔细比较就会发现两派人都有道理,但是assumption不用。

在IT shop工作的人当然喜欢database independant,应为他们为不同公司开发类似应用,能复用最好。而且不同的公司用的数据库肯定五花八门,迁移麻烦越少越好。

但是在企业内部的IT人员来说就是另外一回事了。尤其DBA要考虑的不是单一应用,而是要支持整个企业已有的和未来的应用。约束当然不能全写在application layer,一部分肯定要作为SP写在数据库里(像金融机构有些数据库只能通过SP访问)。这样不同的应用就不需要重复这些约束。至于数据库中立那就更是浪费花很多钱买来的特性了,也限制了可能的优化。

说到底还是要具体情况具体分析



Blog

作者 Re:hibernate or ibatis? [Re:sanshaoye]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2005-05-01 11:41 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
I don' think this argument is misunderstood, and not reasonable at all.

一派人认为应用程序应该是database independant,反对SP,应为那个不够OO.

using sp has nothing to do with oo, as long as you don't put something to somewhere it doesn't belong, i.e., database operations should be in database, business operations in business layers.

sp is faster, more secure. For example, for sensitive business, like banks, miltary industry, there should be no super/god account that can run *any* SQL statement on the production data(You don't want your bank account updated by unauthorized personel). Instead, only certain sps can be run by certain accounts.


另一派认为更换数据库是不现实的,所以应该充分利用不同数据库各自的优化特性。

I am doing two migrations right now. It's just a damn database. Yes, of course we should use 数据库各自的优化特性 whenever possible. But that's not the reason why we should blindly put everything in db. We should still uphold the encapsulation rule. And it's a remote call too.



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:hibernate or ibatis? [Re:sanshaoye]
wwwterloo





发贴: 1
积分: 0
于 2005-05-09 11:13 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我的理解两者并不矛盾。

任何一个应用都应该database independant,能通过修改配置就适应不同db.

db本身的优化都应该包含在db之内,和商业逻辑无关。和OO更加无关。

DB仅仅是一个功能强大的数据源而已。仅此。

另外,像proc,trigger之类的东东,即使使用,也还是按照上面的原则。包含在db之内。尽量避免在应用里直接控制或调用。 这样本身的可维护性太差。

但hb的功能确实还不够强大。对复杂的组合查询,还是需要直接写sql




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923