title: EclipseLink-6015 Invalid query key [customer] in expression
body: <p>What I need to get are all <code>Event</code>s where <code>CustomerEvent.customer.id = 123</code>. What I actually get is exception.</p>
  
  <p>Simplified entities with relevant members only:</p>
  
  <pre><code>@Table(name = "EVENT")
  @Entity
  @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
  @DiscriminatorColumn(name = "TYPE", discriminatorType = DiscriminatorType.STRING, length = 1)
  public abstract class Event {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Basic(optional = false)
      @Column(nullable = false)
      private Integer id;
  }
  
  @Entity
  @DiscriminatorValue("C")
  public class CustomerEvent extends Event {
      @ManyToOne(optional = false)
      private Customer customer;
  }
  
  @Entity
  @Table(name = "CUSTOMER")
  public class Customer {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Basic(optional = false)
      @Column(nullable = false)
      private Integer id;
  
  }
  </code></pre>
  
  <p>Query:</p>
  
  <pre><code>final CriteriaBuilder cb = em.getCriteriaBuilder();
  final CriteriaQuery&lt;Event&gt; cq = cb.createQuery(Event.class);
  final Root&lt;Event&gt; root = cq.from(Event.class);
  cq.select(root);
  cq.where(cb.equal(((Root&lt;CustomerEvent&gt;) root.as(CustomerEvent.class)).get(CustomerEvent_.customer).get(Customer_.id), 123));
  
  // this predicate doesn't work either: cb.isNotNull(((Root&lt;CustomerEvent&gt;) root.as(CustomerEvent.class)).get(CustomerEvent_.customer));
  
  em.createQuery(cq).getResultList(); // throws exception
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code>Exception [EclipseLink-6015] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.QueryException
  Exception Description: Invalid query key [customer] in expression.
  Query: ReadAllQuery(referenceClass=Event )
      at org.eclipse.persistence.exceptions.QueryException.invalidQueryKeyInExpression(QueryException.java:691)
  </code></pre>