Mapping Relationships with Hibernate

Mapping Relationships with Hibernate

Author: Trevor Page: Java Guru | Programmer | Teacher July 23, 2014 Duration: 55:48

In the past we have learned about database relationships, specifically the One-to-Many as well as the Many-to-Many and One-to-One and that was all good, great and grand…

But now I want to talk about how to create those same relationships inside of Hibernate.

Specifically, I want to focus on the One-to-Many relationship in Hibernate and how we go about mapping it out in our Java objects.

But before we do, a word on unidirectional and bidirectional relationships.

Unidirectional vs Bidirectional

In Hibernate, it's possible to map all three relationships that are available in a standard database, these include:

  • One-to-One
  • One-to-Many
  • Many-to-Many

But what Hibernate also includes is the ability to make EACH of those relationships either unidirectional or bidirectional.

This means that we can have a unidirectional One-to-One and a bidirectional One-to-One mapping, as well as a unidirectional One-to-Many and a bidirectional One-to-Many, as well as a unidirectional Many-to-Many and a bidirectional Many-to-Many relationship.

That's a lot of relationships!

So what exactly are unidirectional and bidirectional relationships?

Learn more on the show notes page via http://howtoprogramwithjava.com/session53


The How to Program with Java Podcast is a practical guide for anyone wanting to build software, from curious beginners to those looking to solidify their professional skills. Host Trevor Page, a seasoned Java guru and teacher, breaks down complex programming concepts into clear, manageable lessons you can apply immediately. You'll hear detailed walkthroughs on building applications, understanding core principles like object-oriented design, and navigating the tools of the trade. The discussions move beyond dry theory, focusing on the real-world logic and problem-solving that defines a career in software development. Whether you're aiming for a new job, tackling a personal project, or helping a child explore technology, this podcast provides a structured, conversational path forward. Each episode is crafted to demystify the process, translating technical jargon into plain English so you can focus on creating functional code. The tone is direct and encouraging, rooted in Trevor's experience as both a programmer and an educator. It’s a resource for building a tangible skill set, episode by episode, where consistent listening translates directly to growing competency. You’ll find the content naturally bridges the categories of technology education and career development, making it a useful companion for your learning journey.
Author: Language: English Episodes: 113

How to Program with Java Podcast
Podcast Episodes
Java Observer, Observable Design Pattern [not-audio_url] [/not-audio_url]

Duration: 40:18
Today let's talk about some design patterns, namely the Observer design pattern which can be used in Java. Following the Oberser design pattern in Java is as easy as extending the Observable object and implementing the O…
Interview w/ Self-Taught Programmer Troy Davis [not-audio_url] [/not-audio_url]

Duration: 1:14:51
In this epsidoe of the How to Program with Java podcast, I talk with a self-taught programmer who has started up his own very successful marketing product based on his programming knowledge. Troy was graduated with a deg…
The Agile Development Methodology [not-audio_url] [/not-audio_url]

Duration: 42:17
If you've worked as a developer for a corporation, you've likely been exposed to the waterfall model of software development... If not, consider yourself lucky. I've worked in this model before and it had its issues, but…
Alan Robbins - Self-taught Programmer Success Story [not-audio_url] [/not-audio_url]

Duration: 43:52
Alan Robbins is a self-taught programmer who dabbled with programming in college. After not doing to well in the post-secondary system with respect to programming, he changed his major and graduated with a degree in Busi…
The Software Development Life-Cycle [not-audio_url] [/not-audio_url]

Duration: 52:11
Knowing how to program with Java is only some of the battle when it comes to developing software, the other major part of the battle is knowing HOW to distribute the software. There are entire schools of thought that sur…
Getting a Job as a Self-Taught Programmer [not-audio_url] [/not-audio_url]

Duration: 38:44
Landing a job as a self-taught programmer is not impossible, and I will have an in-depth conversation about why this is the case. I will talk about strategies like creating your own software product based on your own int…
Encapsulation and Final Keyword in Java [not-audio_url] [/not-audio_url]

Duration: 39:55
Learn all about one of the four major principles of Object Oriented Programming (encapsulation) as well as the "final" keyword. In this episode I also dive into the popular topic of Java Certification. Learn what certifi…
Java Interview Question - Part II [not-audio_url] [/not-audio_url]

Duration: 38:20
In this session I will cover some additional Java interview questions that you should be able to answer. I also cover some general tips that you should keep in mind when being interviewed (as it's not just these question…
Java Interview Questions Part I [not-audio_url] [/not-audio_url]

Duration: 45:51
This is part I of a series of episodes dedicated to common questions that are asked in entry level Java interview situations. The questions covered in this episode are some basic questions that I uncovered across the int…