首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Hibernate 抓取 除去重复 解决方案

2012-10-11 
Hibernate 抓取 去除重复 解决方案其实,对于Hibernate 的 Lazy ?可以说是又爱又恨?不过好像细想,爱是自然,

Hibernate 抓取 去除重复 解决方案

其实,对于Hibernate 的 Lazy

?

可以说是又爱又恨

?

不过好像细想,爱是自然,恨嘛...? 个人觉得还是恨自己的技术不过关吧

?

Lazy 懒加载 和 Fetch 抓取

?

是对相反的东西

?

用好了相当于可以自由切换Hibernate配置中的 lazy = "xxx" 这个属性

?

情景:

?

一个 ACL 有很多 Power ,他们是一 (ACL)?对多 (Power) 关系

?

所有ACL端有

Hibernate:     select        distinct acl0_.id as id19_0_,        powers1_.id as id24_1_,        acl0_.aclName as aclName19_0_,        powers1_.isApply as isApply24_1_,        powers1_.powerCreate as powerCre3_24_1_,        powers1_.powerDelete as powerDel4_24_1_,        powers1_.powerLoad as powerLoad24_1_,        powers1_.powerName as powerName24_1_,        powers1_.theAcl_id as theAcl8_24_1_,        powers1_.powerUpdate as powerUpd7_24_1_,        powers1_.theAcl_id as theAcl8_0__,        powers1_.id as id0__     from        t_acl acl0_     inner join        t_power powers1_             on acl0_.id=powers1_.theAcl_id

?

成功解决!

?

PS : 当然我上面用了 inner join fetch,改成left join 更好

?

热点排行