从JavaPOJO类生成hibernate查询
我想从pojo类进行hibernate查询,但pojo类使用从JavaPOJO类生成hibernate查询,java,hibernate,spring-data-jpa,hql,crud,Java,Hibernate,Spring Data Jpa,Hql,Crud,我想从pojo类进行hibernate查询,但pojo类使用mappedBy。我不知道怎样才能提出正确的问题 我已经尝试过很多想法,比如ts.clientAccount.clientAccountMapping.id,但它给出了错误clientAccountMapping在clientAccountpojo中映射 头等舱 public class Transaction{ @ManyToOne @JoinColumn private ClientAccount clien
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;
}
二等舱
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\u0.idtransactio0\u0.clientAccount\u accountIdclientAccount.clientAccountMapping]
你必须在这里使用join。类似:
来自ClientAccount c加入c.clientAccountMapping
参考资料:谢谢,它正在工作。事务ts加入ts.clientAccount.clientAccountMapping映射其中mapping.id竖起大拇指!!