|
236 | 236 | - `@JoinColumn`
|
237 | 237 | - `@JoinColumn`
|
238 | 238 |
|
| 239 | +28. __`MappedBy` & `@JoinColumn` usage__<br> |
| 240 | + JPA Relationships can be either unidirectional or bidirectional. It simply means we can model them as an attribute on exactly one of the associated entities or both. |
239 | 241 |
|
| 242 | + Defining the direction of the relationship between entities has no impact on the database mapping. It only defines the directions in which we use that relationship in our domain model. |
| 243 | + |
| 244 | + For a bidirectional relationship, we usually define: |
| 245 | + - the owning side |
| 246 | + - inverse or the referencing side |
| 247 | + |
| 248 | + The `@JoinColumn` annotation helps us specify the column we’ll use for joining an entity association or element collection. On the other hand, the `mappedBy` attribute is used to define the referencing side (non-owning side) of the relationship. |
240 | 249 |
|
241 | 250 |
|
242 | 251 |
|
|
0 commit comments