2
@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);

我尝试了上面的查询,它抛出了非法的取消引用集合的尝试。关系是
User - Profile OneToOne 和 User - Request OneToMany

我想选择所有未发送请求的用户配置文件,但自己的配置文件除外。

4

1 回答 1

1

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

于 2012-10-27T09:37:23.667 回答