• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Path Expression

 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
EJB 3 in Action, end of page 360 & starting of 361

You can navigate further to other persistence fields or association fields using
a single-value path expression. For example, say we have a many-to-one relationship
between Category and User; we can navigate to a persistence field such as
firstName using association field user as follows:

1
c.items.user.firstName


We may also want to navigate to the association field contactDetails to use its
e-mail address:

1
c.items.user.contactDetails.email

While using path expressions, keep in mind that you cannot navigate through the
collection-value path expressions to access a persistence or association field as in
the following example:

2
c.items.itemName or c.items.seller

This is due to the fact you cannot access an element of a Collection, and items is
in fact is a collection of items. Using c.items.itemName in JPQL is similar to using

category.getItems().getItemName(), and this is not allowed.

Doubt:
I am not able to understand difference between two cases....
c.items.user is valid
c.items.seller is not valid
Please share your thoughts (interperate in your words).....

thanks....
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Deepika Joshi wrote:
Doubt:
I am not able to understand difference between two cases....
c.items.user is valid
c.items.seller is not valid
Please share your thoughts (interperate in your words).....

thanks....


To me, there is no different in these 2 cases.
 
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a mistake in the 1, the book has a mistake. Have you checked the errata:
http://www.manning.com/panda/excerpt_errata.html
You can find this problem there, just do a search for "360".
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for errata list, I was thinking to see it.
 
Deepika Joshi
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also thought that 1. is not correct, and wanted to confirm it.
thanks for EJB 3 in action correction page.....
 
reply
    Bookmark Topic Watch Topic
  • New Topic