from Item item
join item.bids bid
where item.description like '%gc%'
and bid.amount > 100
这样得出来的是两个对象
item 和bid
通过这样进行查询
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
那么只得出的是一个对象