Hello, I am trying to make a query (JPQL) in a relationship 'ManyToOne' and I'm a NullPointerException.
And the same can do via Cypher queries (createNativeQuery)
Code:
TypedQuery<DashboardItem> query = em.createQuery("from DashboardItem WHERE parent = :parentID ORDER BY id", DashboardItem.class);
query.setParameter("parentID", dashboard);
Quote:
Exception in thread "main" java.lang.NullPointerException
at org.hibernate.ogm.type.impl.ManyToOneType.getIdGridType(ManyToOneType.java:56)
at org.hibernate.ogm.type.impl.ManyToOneType.nullSafeSet(ManyToOneType.java:64)
at org.hibernate.ogm.datastore.neo4j.Neo4jDialect.getNamedParameterValuesConvertedByGridType(Neo4jDialect.java:621)
at org.hibernate.ogm.datastore.neo4j.Neo4jDialect.executeBackendQuery(Neo4jDialect.java:572)
at org.hibernate.ogm.query.impl.OgmQueryLoader$OgmQueryLoaderContext.executeQuery(OgmQueryLoader.java:150)
Using native queries runs smoothly
Code:
Query query = em.createNativeQuery("MATCH (n:DashboardItem)-[:parent]->(d:Dashboard) where d.id = {dashID} RETURN n ORDER BY n.id", DashboardItem.class);
query.setParameter("dashID", dashboard.getId());
Entities
Code:
@Entity
public class Dashboard {
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, fetch=FetchType.EAGER)
private Set<DashboardItem> items = new HashSet<DashboardItem>();
}
@Entity
public class DashboardItem {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@ManyToOne
private Dashboard parent;
}
What am I doing wrong?