繁体   English   中英

从java pojo类生成休眠查询

[英]generate hibernate query from java pojo class

我想从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]

您必须在此处使用Join。 像: From ClientAccount c join c.clientAccountMapping

参考: https : //docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM