Skip to content

Commit ef94302

Browse files
committed
2 parents 655db53 + 34bb1ed commit ef94302

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

HibernateSpringBootPopulatingChildViaProxy/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

2-
**[Populating a Child-Side Parent Association via Proxy](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootPopulatingChildViaProxy)**
2+
**[How To Populate a Child-Side Parent Association via Proxy](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootPopulatingChildViaProxy)**
33

44
**Description:** A `Proxy` can be useful when a child entity can be persisted with a reference to its parent. In such cases, fetching the parent entity from the database (execute the `SELECT` statement) is a performance penalty and a pointless action. Hibernate can set the underlying foreign key value for an uninitialized `Proxy`.
55

66
**Key points:**\
77
- rely on `EntityManager#getReference()`\
88
- in Spring, use `JpaRepository#getOne()` -> used in this example\
99
- in Hibernate, use `load()`\
10-
- here, we have two entities, `Tournament` and `TennisPlayer`, and a tournament can have multiple players (`@OneToMany`)\
11-
- we fetch the tournament via a `Proxy` (this will not trigger a `SELECT`), we create a new tennis player, we set the `Proxy` as the tournament for this player and we save the player (this will trigger an `INSERT` in the tennis players table, `tennis_player`)
10+
- here, we have two entities, `Author` and `Book`, and an author have written multiple books (`@OneToMany`)\
11+
- we fetch the author via a `Proxy` (this will not trigger a `SELECT`), we create a new book, we set the `Proxy` as the author for this book and we save the book (this will trigger an `INSERT` in the `book` table)
1212

1313
**Output example:**\
1414
- the console output will reveal that only an `INSERT` is triggered, not the `SELECT`

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,16 @@
166166

167167
-----------------------------------------------------------------------------------------------------------------------
168168

169-
11. **[How To Populate A Child-Side Parent Association Via Proxy](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootPopulatingChildViaProxy)**
169+
11. **[How To Populate a Child-Side Parent Association via Proxy](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootPopulatingChildViaProxy)**
170170

171171
**Description:** A `Proxy` can be useful when a child entity can be persisted with a reference to its parent. In such cases, fetching the parent entity from the database (execute the `SELECT` statement) is a performance penalty and a pointless action. Hibernate can set the underlying foreign key value for an uninitialized `Proxy`.
172172

173173
**Key points:**\
174174
- rely on `EntityManager#getReference()`\
175175
- in Spring, use `JpaRepository#getOne()` -> used in this example\
176176
- in Hibernate, use `load()`\
177-
- here, we have two entities, `Tournament` and `TennisPlayer`, and a tournament can have multiple players (`@OneToMany`)\
178-
- we fetch the tournament via a `Proxy` (this will not trigger a `SELECT`), we create a new tennis player, we set the `Proxy` as the tournament for this player and we save the player (this will trigger an `INSERT` in the tennis players table, `tennis_player`)
177+
- here, we have two entities, `Author` and `Book`, and an author have written multiple books (`@OneToMany`)\
178+
- we fetch the author via a `Proxy` (this will not trigger a `SELECT`), we create a new book, we set the `Proxy` as the author for this book and we save the book (this will trigger an `INSERT` in the `book` table)
179179

180180
**Output example:**\
181181
- the console output will reveal that only an `INSERT` is triggered, not the `SELECT`

0 commit comments

Comments
 (0)