• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

JPA Join Query to display a sectorname from a sectorID foreign key table

 
Ranch Hand
Posts: 222
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My application shows a list oof projects which should include the name of the sector and the name of the country for each project. I"m using Netbeans 7.3 and automatically generating the JPA classes. The list in the JSF page shows projects, description, the sector ID (foreign key), country ID (foreign key). Instead of showing the numeric ID values, I would like the list to show the corresponding string values of the foreign keys (ie: instead of showing sector ID, I"d lik to show sectorname corresponding to the ID).


I try to modify the NamedQuery field in the entity class of the projects table from:



to:





I then create a property for the sectorname (below the sectorID) and write the getters and setters for the sector name. I add the sectorname title in the JSF page and get the following error:





I'm really not sure how to correctly create a JOIN query so that the string are pulled in the project list from the foreign key tables (sector and country). Would apprecoate any advice. I've included the main classes of the app. Please let me know if i need to cut down or add any information. Thanks in advance!



 
And inside of my fortune cookie was this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic