0

我希望,一个人在一次查询中获得该人拥有的每个选定报价的请求列表(例如,'select * from Request r where r.selectedOffer = (select o from Offer r.offerList.owner = :owner(? ?)). 有可能吗?或者我必须使用两个查询(一个用于请求,一个用于报价),然后我必须将选定的报价设置为请求?

@Entity
public class Request() {

.....
@OneToMany(mappedBy = "requestId", fetch = FetchType.LAZY)
private Set<Offer> offerList = new HashSet<Offer>();

@Transient (or @OneToOne(mappedBy = "requestId"?? or another ways?)
private Offer selectedOffer;
.....
}
4

1 回答 1

0

试试下面:

 "FROM Request req JOIN req.offerList offer "+
      " WHERE req.selectedOffer.offerId = offer.offerId AND offer.owner = :owner"

或者我认为这应该这样做:

 "FROM Request req WHERE req.selectedOffer.owner = :owner"

我假设offerIdOffer实体的主键。

于 2012-11-06T16:48:30.347 回答