On this page
bidirectional
Explore "bidirectional" with insightful episodes like "Ep. 17 - Pittini meshes for the Udinese Stadium", "Hibernate @ManyToMany Unidirectional and Bidirectional", "Hibernate @ManyToMany Unidirectional and Bidirectional", "Hibernate @ManyToMany Unidirectional and Bidirectional" and "Hibernate @OneToOne Unidirectional / Bidirectional" from podcasts like ""#BeAhead - The thousand faces of steel", "How to Program with Java Podcast", "How to Program with Java Podcast", "How to Program with Java Podcast" and "How to Program with Java Podcast"" and more!
Episodes (10)
Hibernate @ManyToMany Unidirectional and Bidirectional
Hibernate @ManyToMany Unidirectional
The Many-to-Many relationship can be best described by example.
The example we’re going to use is that of the relationship between an Author
and a Book
.
Author
s publish Book
s, and Book
s have Author
s. Any one Author
can publish many Book
s, and any one Book
can be published by many Author
s, so this is why it is a many to many relationship.
Other examples of the many to many relationship are Students to Courses and Employees to Projects.
Let’s take a look at how the unidirectional many-to-many relationship is created using Hibernate... for more info please visit http://howtoprogramwithjava.com/session56
Hibernate @ManyToMany Unidirectional and Bidirectional
Hibernate @ManyToMany Unidirectional
The Many-to-Many relationship can be best described by example.
The example we’re going to use is that of the relationship between an Author
and a Book
.
Author
s publish Book
s, and Book
s have Author
s. Any one Author
can publish many Book
s, and any one Book
can be published by many Author
s, so this is why it is a many to many relationship.
Other examples of the many to many relationship are Students to Courses and Employees to Projects.
Let’s take a look at how the unidirectional many-to-many relationship is created using Hibernate... for more info please visit http://howtoprogramwithjava.com/session56
Hibernate @ManyToMany Unidirectional and Bidirectional
Hibernate @ManyToMany Unidirectional
The Many-to-Many relationship can be best described by example.
The example we’re going to use is that of the relationship between an Author
and a Book
.
Author
s publish Book
s, and Book
s have Author
s. Any one Author
can publish many Book
s, and any one Book
can be published by many Author
s, so this is why it is a many to many relationship.
Other examples of the many to many relationship are Students to Courses and Employees to Projects.
Let’s take a look at how the unidirectional many-to-many relationship is created using Hibernate... for more info please visit http://howtoprogramwithjava.com/session56
Hibernate @OneToOne Unidirectional / Bidirectional
One-to-One Unidirectional Relationship
Since you’ve already learned about the ins and outs of how unidirectional one-to-many and bidirectional one-to-many relationships work, it’s time to learn about the One-to-One relationships.
We will start things off with the unidirectional One-to-One relationship and how it’s set up in Hibernate.
First thing is first, you need to understand how a One-to-One relationship is actually set up in a database. Once you understand that the child table declares the parent’s primary key as the child’s primary key, then we can get moving with the Hibernate stuff!
For this example, we are going to use the One-to-One relationship between an Employee
and their Address
. TheAddress
table will be set up as follows:
For more information, please read the show notes via http://howtoprogramwithjava.com/session55
Hibernate @OneToOne Unidirectional / Bidirectional
One-to-One Unidirectional Relationship
Since you’ve already learned about the ins and outs of how unidirectional one-to-many and bidirectional one-to-many relationships work, it’s time to learn about the One-to-One relationships.
We will start things off with the unidirectional One-to-One relationship and how it’s set up in Hibernate.
First thing is first, you need to understand how a One-to-One relationship is actually set up in a database. Once you understand that the child table declares the parent’s primary key as the child’s primary key, then we can get moving with the Hibernate stuff!
For this example, we are going to use the One-to-One relationship between an Employee
and their Address
. TheAddress
table will be set up as follows:
For more information, please read the show notes via http://howtoprogramwithjava.com/session55
Hibernate @OneToOne Unidirectional / Bidirectional
One-to-One Unidirectional Relationship
Since you’ve already learned about the ins and outs of how unidirectional one-to-many and bidirectional one-to-many relationships work, it’s time to learn about the One-to-One relationships.
We will start things off with the unidirectional One-to-One relationship and how it’s set up in Hibernate.
First thing is first, you need to understand how a One-to-One relationship is actually set up in a database. Once you understand that the child table declares the parent’s primary key as the child’s primary key, then we can get moving with the Hibernate stuff!
For this example, we are going to use the One-to-One relationship between an Employee
and their Address
. TheAddress
table will be set up as follows:
For more information, please read the show notes via http://howtoprogramwithjava.com/session55
Hibernate @OneToMany Bidirectional Relationship
Since we’ve already learned about the unidirectional @ManyToOne relationship, we can now move on to talking about what a bidirectional relationship is like, when using Hibernate. The term “bidirectional” literally means “functioning in two directions”, which is the concept that we will apply in our relationships between two Java objects. When we have a bidirectional relationship between objects, it means that we are able to access Object A from Object B, and Object B from Object A. We can apply this logic to our real world coding example that we saw in the last post. The example we will use is the relationship between an Employer and an Employee. Previously, we only defined a unidirectional relationship, so we could only access the Employer from the Employee object and not vice-versa. Now let’s take a look at how to transform our existing unidirectional relationship into a bidirectional one.
Hibernate @OneToMany Bidirectional Relationship
Since we’ve already learned about the unidirectional @ManyToOne relationship, we can now move on to talking about what a bidirectional relationship is like, when using Hibernate. The term “bidirectional” literally means “functioning in two directions”, which is the concept that we will apply in our relationships between two Java objects. When we have a bidirectional relationship between objects, it means that we are able to access Object A from Object B, and Object B from Object A. We can apply this logic to our real world coding example that we saw in the last post. The example we will use is the relationship between an Employer and an Employee. Previously, we only defined a unidirectional relationship, so we could only access the Employer from the Employee object and not vice-versa. Now let’s take a look at how to transform our existing unidirectional relationship into a bidirectional one.
Hibernate @OneToMany Bidirectional Relationship
Since we’ve already learned about the unidirectional @ManyToOne relationship, we can now move on to talking about what a bidirectional relationship is like, when using Hibernate. The term “bidirectional” literally means “functioning in two directions”, which is the concept that we will apply in our relationships between two Java objects. When we have a bidirectional relationship between objects, it means that we are able to access Object A from Object B, and Object B from Object A. We can apply this logic to our real world coding example that we saw in the last post. The example we will use is the relationship between an Employer and an Employee. Previously, we only defined a unidirectional relationship, so we could only access the Employer from the Employee object and not vice-versa. Now let’s take a look at how to transform our existing unidirectional relationship into a bidirectional one.