Issue Type: Improvement Improvement
Affects Versions: 4.1.9
Assignee: Unassigned
Components: entity-manager, query-criteria
Created: 26/Dec/12 8:05 PM
Description:

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.

Environment: java oracle 7
Project: Hibernate ORM
Labels: hibernate jpa2 criteria
Priority: Major Major
Reporter: HĂȘndi Marcos
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira