from Item item
join item.bids bid
where item.description like '%gc%'
and bid.amount > 100
這樣得出來(lái)的是兩個(gè)對(duì)象
item 和bid
通過(guò)這樣進(jìn)行查詢
Query q = session.createQuery("from Item item join item.bids bid");
Iterator pairs = q.list().iterator();
Joining associations 263
while ( pairs.hasNext() ) {
Object[] pair = (Object[]) pairs.next();
Item item = (Item) pair[0];
Bid bid = (Bid) pair[1];
}
如果是
select item
from Item item
join item.bids bid
where item.description like '%gc%'
and bid.amount > 100
那么只得出的是一個(gè)對(duì)象