This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术讨论 / 【Hibernate Discussion 由于原贴太长,这里再开一贴】昨日发了一篇关于Hibernate工作面试失败有感的贴子,未曾想到引起了众多 XDZM 的兴趣。争论,赞成,反对的都有。希望通过讨论,大伙儿都能有所提高,在技术上,和开会argue时 (“科学骂人”的那种,呵呵)。An outstanding question is 一兄弟说了下面的话。此话可能有点极端,但俺基本赞成。您呢?
For the N-tier web app running in an app server, lazy loading is useless. And by default, we always set it to false. -wukongjj(不经历风雨怎么见彩虹); 10.28 17:08 (#5640620@0)
-james05(关不上的窗);
2009-10-29
{263}
(#5642072@0)
-
Completely agree. Momory is really cheap these days. Performance outweighs the memory consumption.
-qulaopo(娶老婆);
2009-10-29
(#5642172@0)
-
Performace and scalability is 2 different things. I can develop an application that load everything, code, data into memory as soon as the application launched. The system would have great performance, but it may not be scalable!Say for example, I have a huge financial calculator which can use 1 GB memory for the executable + data. So even with a servr with 128 GB memeory, you may only be able to launch about 100 instances.
With proper design, you can host the application on the same machine that supports 500 concurrent users with 30% less slower.
You have to balance between budget / performance / scalability.
-hkchan(0);
2009-10-29
{397}
(#5642261@0)
-
Gavin 千方百计的想大家使用他的LAZY LOADING,首先他搞了个OPEN SESSION IN VEW PATTERN, 后来他在写SEAM 的时候又引入了CONVERSTION
为什么大家还是有点不买账。还是要把他的LAZY LOADING 设成 FALSE? 是什么原因? HIBERNATE ,SEAM 和JPA都出自一个牛人Gavin。
-who8mylunch(java中年失业男);
2009-10-29
{201}
(#5642512@0)
-
我自己从不用LAZY LOADING, 一则没太有必要, 大不了加内存呗, 二则影响PERFORMANCE, 该LOAD的东西一开始就LOAD不是更好吗?三则不安全, 虽然是OPEN SOURCE,没谁有时间去看它怎么实现的, 保证SYNC很麻烦的, 万一他那儿有BUG怎么办?
-javacup(风铃);
2009-10-29
(#5644148@0)
-
大系统, 像Oracle Agile PLM, 没有Lazy Loading, 用户自定义的class, subclass, process extension根本就无从实现. 这是系统custom design 的必须.
-nicetomeetyou(蓦然回首彩虹跨天地);
2009-10-29
(#5644175@0)
-
这就不对了。lazy loading会导致n+1问题。但是,单纯地设定lazy=false会导致1+1问题(如果你不care多一个数据库的round trip,那当我没说)。fetch=Subselect和join的目的,就是把1+1的那个1去掉,只用一个sql,一个数据库round trip就可以了。
-crashingwaves(CherryHill);
2009-10-30
(#5644437@0)
-
ORM 太落后了, 我们现在用PURE-XML, XML 一存就好了。数据读取全用XPATH,100mb 的XML 有专门的压缩器提高perfromance。
-sxffff(Felix);
2009-10-29
(#5644293@0)
-
压缩啥,这不是size的问题。你知道Dom4J parse Xpath有多慢吗?Xpath只是一个syntactic sugar而已。你们的应用肯定不是time critical的,也不scalable to thousands of users。除非你们自己implement一个XML representation。
-crashingwaves(CherryHill);
2009-10-30
(#5644449@0)
-
pure XML也太落后了, 现在都JSON代替了, 又快又简洁.
-mfcguy();
2009-11-9
(#5667690@0)
-
lazy loading有没有用取决于你怎么使用ORM很多人觉得lazy loading没用是因为他们只是简单的做个table 到object的映射,并没有建立一个big object graph.对于前者,每次操作比较清晰简单,涉及到的object不多,所以lazy loading 看不出什么优势;但是对于后者,在一个object graph 中navigation,只有需要在这数据的时候才load可以避免一开始就load大量数据,但是实际上后面并不使用的情况。多数人还是thinking in Database tables, not thinking in Objects。hibernate不仅仅帮你做了table<->object mapping, 还通过association使建立一个object graph 同时隐藏背后数据库操作成为可能。
-iga(nikita);
2009-11-18
{505}
(#5688807@0)
-
最近刚好搞了点hibernate performance tuning,如果在内存不是非常紧张的情况下那个lazy-loading对性能提高真的没用,使用二级CACHE,系统性能提高很快!
-zhousx18(心想事成);
2009-12-5
(#5728016@0)