Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1435825
  • 博文数量: 18
  • 博客积分: 9950
  • 博客等级: 中将
  • 技术积分: 4242
  • 用 户 组: 普通用户
  • 注册时间: 2004-10-08 10:08
文章分类

全部博文(18)

文章存档

2009年(3)

2008年(15)

我的朋友

分类: 系统运维

2008-07-26 16:20:46

 
 
主要的地方:
getHibernateTemplate.load() 存在延迟加载问题。
getHibernateTemplate.get()  不存在此问题,她是不采用lazy机制的。
1  当记录不存在时候,get方法返回null,load方法产生异常,即get()可以取空的数据集,但load()不行。  
       take a look at the Hibernate documentation (though I agree is not very explicit)--the HibernateTemplate is basically a wrapper around the native Hibernate API.
       get() will return null if an object is not found while load() will always return a  
non-null object which is a proxy. If the underlying object does not exist, the proxy  will thrown ObjectNotFoundException.
       load() should be used when you are sure that the object exits while get() when
you're not.
 
 
2  load方法可以返回实体的代理类,get方法则返回真是的实体类
3  load方法可以充分利用hibernate的内部缓存和二级缓存中的现有数据,而get方法仅仅在内部缓存中
进行数据查找,如果没有发现数据則将越过二级缓存,直接调用SQL查询数据库。
4  也许别人把数据库中的数据修改了,load如何在缓存中找到了数据,则不会再访问数据库,而get则
会返回最新数据。
 
 
 
 
 
 
 
 
 
阅读(5164) | 评论(0) | 转发(0) |
0

上一篇:arp 命令

下一篇:windows下 python的安装配置

给主人留下些什么吧!~~