• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Path expressions in JPA

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

I fail to understand what and how we cannot traverse beyond a collection in a path expression? For example in the EJB 3 in Action series, on page 360, it is stated that we can navigate to other persistence fields or association fields using a single-valued path expression. I cannot understand this...

How is c.items.user.firstName different from c.items.itemName or c.items.seller?? (This is from the EJB 3 in Action book)
 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

How is c.items.user.firstName different from c.items.itemName or c.items.seller?? (This is from the EJB 3 in Action book)



The difference between c.user.firstName and c.items.itemName (or c.items.seller) is the relationship between the entities. On page 360 of EJB 3 in Action is written:

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



If you compare this now with the incorrect statements c.items.itemName and c.items.seller, then you find again on page 361 the answer why this statements are wrong

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



With c.items.itemName and c.items.seller it is not clear which itemName or which seller do you want, because there is not only one unique.


 
No one can make you feel inferior without your consent - Eleanor Roosevelt. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic