Eager Loading is a design pattern in which data initialization occurs on the spot
๐๋ฐ์ดํฐ ์ด๊ธฐํ๊ฐ ๊ทธ ์๋ฆฌ์์ ์ผ์ด๋๋ ๋์์ธ ํจํด
Lazy Loading is a design pattern which is used to defer initialization of an object as long as it's possible
๐๊ฐ๋ฅํ ํ ๊ฐ์ฒด ์ด๊ธฐํ๋ฅผ ์ฐ๊ธฐํ๋ ๋ฐ ์ฌ์ฉ๋๋ ๋์์ธ ํจํด
Eager Loading์ ์ฌ์ฉ์ ๋ฐ์ดํฐ๋ฅผ ๋ก๋ํ๋ฉด ๊ด๋ จ๋ ๋ชจ๋ ์ฃผ๋ฌธ๋ ๋ก๋ํ๊ณ ๋ฉ๋ชจ๋ฆฌ์ ์ ์ฅํฉ๋๋ค
๊ทธ๋ฌ๋ ์ง์ฐ ๋ก๋ฉ์ด ํ์ฑํ๋์ด ์์ ๋ UserLazy ๋ฅผ ํ์
ํ๋ฉด OrderDetail ๋ฐ์ดํฐ๋ ๋ช
์์ ์ผ๋ก ํธ์ถ๋ ๋๊น์ง ์ด๊ธฐํ๋์ง ์๊ณ ๋ฉ๋ชจ๋ฆฌ์ ๋ก๋๋ฉ๋๋ค.
fetch = FetchType.LAZY
fetch = FetchType.EAGER
@OneToMany ์ด๋
ธํ
์ด์
์ FetchType.LAZY ๊ฐ Default๋ก ์ค์
@ManyToOne ์ด๋
ธํ
์ด์
์ FetchType.EAGER ๊ฐ Default๋ก ์ค์