Hibernate - Fetching associations
关键字: hibernate刚又去看了看Hibernate in action,fetching associations
In HQL, you can specify that an association should be eagerly fetched by an
outer join using the fetch keyword in the from clause:
from Item item left join fetch item.bids where item.description like '%gc%'
This query returns all items with a description that contains the string gc, and all
their bids, in a single select. When executed, it returns a list of Item instances, with
their bids collections fully initialized. We call this a from clause fetch join. The purpose
of a fetch join is performance optimization: We use this syntax only because
we want eager initialization of the bids collections in a single SQL select
■ HQL always ignores the mapping document eager fetch (outer join) setting. If
you’ve mapped some associations to be fetched by outer join (by setting
outer-join="true" on the association mapping), any HQL query will ignore
this preference. You must use an explicit fetch join if you want eager fetching
in HQL.
原来在映射文件里设置了outer-join="ture",如果在HQL不用fetch的话,一样不会initialized.
希望大家也注意一下:)
BTW:join fetch很好用,前面不知道,每次在jsp因为没有initialized关闭了session而头痛:)
发表评论
- 浏览: 9286 次
- 性别:

- 来自: 乌鲁木齐

- 详细资料
搜索本博客
最近加入圈子
链接
最新评论
-
EXT的性能讨论
路过,很了不起,这是我见到的第一个EXT网站.
-- by ffychina -
扩展EXT Comobox功能的代 ...
你好,我想问一下,select 标签的 size 属性,在ext的comobox ...
-- by stevenzuo -
一步一个脚印慢慢来
嗯。。是啊。。
-- by j_butterfly -
一步一个脚印慢慢来
是用java做的吧
-- by qichunren -
show一下我用EXT2.0做的记 ...
很不错,,能有一个公用demo帐号就好了
-- by lvscar






评论排行榜