我想从pojo类进行休眠查询,但是pojo类使用mappedBy
。我不知道如何进行正确的查询。
我已经尝试了很多想法,例如ts.clientAccount.clientAccountMapping.id
,但它给出了错误。 clientAccountMapping
映射到clientAccount
pojo
头等舱
public class Transaction{
@ManyToOne
@JoinColumn
private ClientAccount clientAccount;
}
二等班
public class ClientAccount{
@JsonIgnore
@OneToMany(mappedBy = "clientAccount", cascade = CascadeType.ALL)
private Set<ClientAccountMapping> clientAccountMapping;
}
三等班
public class ClientAccountMapping{
@Id
@GeneratedValue(generator="system-uuid")
@GenericGenerator(name="system-uuid", strategy = "uuid")
private String id;
}
我的编译器总是给出以下异常:
org.hibernate.QueryException:非法尝试取消对集合的引用[transactio0_.idtransactio0_.clientAccount_accountIdclientAccount.clientAccountMapping]
答案 0 :(得分:1)
您必须在此处使用Join。像:From ClientAccount c join c.clientAccountMapping
参考:https://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html