Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Path expressions in JPA

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • 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)
 
Christian Nicoll
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • 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.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic