我有两个模型对象:
Ws.java:
public class Ws {
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "wsfgs", joinColumns = @JoinColumn(name = "ws_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "fg_id", referencedColumnName = "id"))
private List<Fg> fgs;
}
Fg.java:
public class Fg {
@ManyToMany(mappedBy = "fgs")
private List<Ws> wss;
}
如果我要编写这样的查询:
SELECT w FROM Ws w WHERE :anFgObject IN w.fgs
或类似这样:
SELECT w From Ws w WHERE w.fgs IS NULL
我只收到“ org.hibernate.exception.SQLGrammarException:无法提取ResultSet”消息。显然我得到了SQL语法错误。我做错了什么?这不是解决问题的正确方法吗?不幸的是,我找不到任何合适的资源来告诉我如何检查List属性是否为空。