Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

Ranch Hand
Posts: 222
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • 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:


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!

If you two don't stop this rough-housing somebody is going to end up crying. Sit down and read this tiny ad:
Rocket Oven Kickstarter - from the trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!