我有下一个ER结构:
我的实体是这样的:
Event.java
public class Event implements Serializable {
.. many attributes here
@OneToOne(mappedBy = "evento",cascade = CascadeType.ALL,orphanRemoval = true)
private Quiz quiz;
many getters & setters here ...
}
Quiz.java
public class Quiz implements Serializable {
@JoinColumn(name = "evento",referencedColumnName = "id")
@OneToOne
private Evento evento;
}
我想在没有测验的情况下获取每个事件,所以我的查询是这样的:
Query q = em.createQuery("SELECT e FROM Evento AS e WHERE e.encuesta IS NULL",Evento.class);
但我得到一个空列表
我正在使用hibernate进行持久化。
有人可以帮助我:)?
答案 0 :(得分:0)
尝试IS EMPTY
子句:
Query q = em.createQuery("SELECT e FROM Evento AS e WHERE e.encuesta IS EMPTY",Evento.class);
见: