I am trying to learn Java Persistance API. So it is written on page174 of JPA 2.1 specification :
In the following example, contactInfo denotes an embeddable class consisting of an address and set of phones. Phone is an entity.
SELECT p.vendor FROM Employee e JOIN e.contactInfo.phones p
WHERE e.contactInfo.address.zipcode = '95054'
The following query is equivalent to the query above:
SELECT p.vendor FROM Employee e JOIN e.contactInfo c JOIN c.phones p WHERE e.contactInfo.address.zipcode = '95054'
then on page 176: The query below joins over Employee, ContactInfo and Phone. ContactInfo is an embeddable class that consists of an address and set of phones. Phone is an entity.
SELECT p.vendor FROM Employee e JOIN e.contactInfo c JOIN c.phones p WHERE c.address.zipcode = '95054'
So when I try to execute such queries only the first works. The last two queries cause error: Exception in thread "main" java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: Exception Description: Problem compiling [SELECT p.vendor FROM Employee e JOIN e.contactInfo c JOIN c.phoneNumbers p WHERE c.address.zipcode = 'zip2']. [37, 50] The collection-valued path 'e.contactInfo' must resolve to an association field.
Could anyone explain why is that? I also tried to reproduce other examples of joins to embeddable classes from the specification, but always got the same error.
Thank you Best regards