gpt4 book ai didi

java - JPA : illegal attempt to dereference collection

转载 作者:行者123 更新时间:2023-11-30 11:39:46 25 4
gpt4 key购买 nike

@Entity
@Table(name="users")
public class User implements Serializable
{
private List<Request> sentRequest;
private List<Request> receivedRequest;
private Profile profile;
}

public List<Object> getUserProfiles(Integer userid)
{
query = em.createQuery(
"SELECT p from Profile p1,Profile p2 WHERE " +
"p1.user.sentRequest.sender.id (:id) NOT IN " +
" p2.user.receivedRequest.receiver.id and " +
"p1.user.id NOT IN (:id)"
).setParameter("id",userid);

我在上面的查询中试过它正在抛出对取消引用集合的非法尝试。关系是
用户 - 配置文件 OneToOne 和用户 - 请求 OneToMany

我想选择所有未发送请求的用户个人资料,除了自己的个人资料。

最佳答案

问题是这部分代码 p1.user.sentRequest.sender.id (:id) NOT IN 参数必须在 NOT IN 之后,像这样 p1.user.sentRequest.sender.id NOT IN (:id)

关于java - JPA : illegal attempt to dereference collection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13097185/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com