Posts tonen met het label Illegal attempt to dereference path source. Alle posts tonen
Posts tonen met het label Illegal attempt to dereference path source. Alle posts tonen

maandag 25 juli 2011

ERROR - java.lang.IllegalArgumentException: Illegal attempt to dereference path source [null]

Using: 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

initial code:
Root root = criteriaQuery.from(Order.class);
Path path = root.get(key); //path to OrderLines
path = path.get("description"); //throws exception since Ordelines was a many to many join

new code:
Root root = criteriaQuery.from(Order.class);
Join join = criteriaQuery.join("orderLines");
Path path = root.get(key); //path to OrderLines
path = join.get("description");