This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

JPA Entity Relationships Newbie Questions  RSS feed

 
Greenhorn
Posts: 8
Flex MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

This is my first post so I hope I am going about this the right way. I am working on my first JPA project ever so this may seem like some very basic questions but please bear with me.

My work has me putting together a database for all of the awards we have given out over the last 40 years to our faculty and students. My database structure looks kind of like the picture I have attached to this post. We have about 850 award instances of the 30 or so awards we give out each year. They have been given to about 500 different people and some people have received an award multiple times or multiple awards.

I understand that my Award Instances table has a many to one relationship with each of the other tables but how do I show that in my entities?? Do I treat my Awards Instances table as one big join table??

I've looked at lots of examples but all of them are usually just 2 tables. I'm not sure how to treat something more complex.

Thanks for any help you guys are willing to give!
Database-Relationships.jpg
[Thumbnail for Database-Relationships.jpg]
Database Jpeg
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't really see the need for the Year Awarded entity. Why not just make a date field in "Instance of Award". By the way I don't really like that name. Also the name of the entity "Award Name" is weird. Why not name it Award with a field name?

Coding a ManyToOne relationship isn't that complicated. Could you show us your code (not all but only the relevant)?
 
Calvin Hughes
Greenhorn
Posts: 8
Flex MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah sorry the picture I posted was for brevity to show the general layout of the tables. Each table other than the year shows more detail and has a different naming scheme. To be honest I think I am over thinking things. I'm still studying up on how to use JPA and JPQL. Other than mapping out the relationships between tables in the entities, working with how the tables data all comes together should be in my queries right? wow I feel like that is a really dumb question.

I'll post some code when I actually have an example to show.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!