ERROR - java.lang.IllegalArgumentException: Illegal attempt to dereference path source [null]
Using: Criteria JPA 2 with hibernate
Stacktrace:
java.lang.IllegalArgumentException: Illegal attempt to dereference path source [null]
at org.hibernate.ejb.criteria.path.AbstractPathImpl.illegalDereference(AbstractPathImpl.java:104)
at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:186)
Cause:
I was doing a get on a PluralAttributePath
Attribute type java.util.List
initial code:
Root root = criteriaQuery.from(Order.class);
Path path = root.get(key); //path to OrderLines (java.util.List)
path = path.get("description"); //throws exception since Ordelines was a many to many join OR one to many
new code:
Root root = criteriaQuery.from(Order.class);
Join join = criteriaQuery.join("orderLines"); (java.util.List)
Path path = root.get(key); //path to OrderLines
path = join.get("description");
========
In others providers the join is implicit
As the queries using criteria are already very verbose, I think it would be a facility.
|