我正在使用JPA 1.0。我有这个JPQL查询
public List<IssEntitat> dummySearchActiusByFilter() {
Query query = entityManager.createQuery("SELECT e FROM IssEntitat e where e.issEdificisList.issPlantesCollection.id = :pIdPlanta");
query.setParameter("pIdPlanta", (long) 3);
return query.getResultList();
}
有我的entities.java
public class IssEntitat implements Serializable {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "id")
private List<IssEdificis> issEdificisList;
}
public class IssEdificis implements Serializable { @JoinColumn(name = "ID_ENTITAT", referencedColumnName = "ID_ENTITAT") @ManyToOne(optional = false) private IssEntitat idEntitat; @OneToMany(cascade = {CascadeType.ALL}, mappedBy = "idEdifici") private Collection<IssPlantes> issPlantesCollection = new ArrayList<>();
}
public class IssPlantes implements Serializable {
@JoinColumn(name = "ID_EDIFICI", referencedColumnName = "ID_EDIFICI")
@ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST}, targetEntity = IssEdificis.class)
private IssEdificis idEdifici;
}
执行JPQL时,错误是
显示java.lang.NullPointerException 在org.hibernate.hql.ast.tree.DotNode.getColumns(DotNode.java:97)
我想通过planta搜索所有的issEntities。问题是实体关系是issEdificis和IssPlantes之间的一对多