JPA多选错误

时间:2018-06-11 12:22:42

标签: hibernate jpa fetch multi-select

在对表进行多选时,获取以下错误,仅获取所选列:

Root<MainTrade> mt= criteriaQuery.from(MainTrade.class);
mt.fetch("etrade",JOIN_TYPE.INNER).fetch("addressList",JOIN_TYPE.INNER);

criteriaQuery.multiselect(mt.get("tradeId"),mt.get("etrade").get("addressList");

Model classes are as below:

Class MainTrade{

@Id
private Integer tradeId;
.....
....
@OneToOne
private ETrade etrade;

}

Class ETrade
{

private Integer tradeId;

@Id
private Integer eTradeId;

@OneToMany
private List<Address> addressList;

}

Class Address
{

 private Integer eTradeId;
 private String streetName
}

在多选中获取错误:

  

引起:org.hibernate.QueryException:查询指定的连接   获取,但获取的关联的所有者不存在   选择列表[FromElement {显式,不是集合连接,获取   join,获取非延迟属性,classAlias = generatedAlias1 ......]

0 个答案:

没有答案