Search
Duplicate
โ˜•

javax.persistence ์–ด๋…ธํ…Œ์ด์…˜ ์ฐฝ๊ณ 

@ElementCollection

โ€ข
Element ๊ฐ์ฒด์˜ ์ปฌ๋ ‰์…˜ ์ง‘ํ•ฉ์ด๋‹ค.
โ€ข
Element ๋กœ๋Š” ๊ธฐ๋ณธ ํƒ€์ž…(String, Long ๋“ฑ) ๊ณผ Embeddable ๋กœ ์„ ์–ธ๋œ ๊ฐ์ฒด๊ฐ€ ๋  ์ˆ˜ ์žˆ๋‹ค.
โ€ข
๋ถ€๋ชจ Entity Id์™€ ์ถ”๊ฐ€ ์ปฌ๋Ÿผ(basic or embedded ํƒ€์ž…)์œผ๋กœ ๊ตฌ์„ฑ๋œ๋‹ค.
โ€ข
๊ธฐ๋ณธ์ ์œผ๋กœ ๊ฐ’ ํƒ€์ž… ์ปฌ๋ ‰์…˜์— ๋ณ€๊ฒฝ ์‚ฌํ•ญ(์ €์žฅ, ์‚ญ์ œ)์ด ๋ฐœ์ƒํ•˜๋ฉด, ์†Œ์œ ํ•˜๋Š” ์—”ํ‹ฐํ‹ฐ์™€ ์—ฐ๊ด€๋œ ๋ชจ๋“  ๋ฐ์ดํ„ฐ๋ฅผ ์‚ญ์ œํ•˜๊ณ , ํ˜„์žฌ ๋‚จ์•„์žˆ๋Š” ๊ฐ’์„ ๋ชจ๋‘ ๋‹ค์‹œ ์ €์žฅํ•œ๋‹ค.

@CollectionTable

โ€ข
@Table ๊ณผ ๊ฐ™์ด Collection ์œผ๋กœ ์„ ์–ธ๋œ ๋ณ€์ˆ˜์— ๋Œ€ํ•œ ํ…Œ์ด๋ธ”์„ ๋งŒ๋“ค ๋•Œ ์‚ฌ์šฉ
โ€ข
์—ฐ๊ด€ ๊ฐ์ฒด์— ์˜์กด์ ์ด๊ธฐ๋•Œ๋ฌธ์— ์˜ต์…˜์œผ๋กœ๋Š” joinColumns ์™€ foreignKey ๊ฐ€ ์žˆ๋‹ค.

@AttributeOverride

โ€ข
column ๋ช…์„ ์ •์˜ํ•  ์ˆ˜ ์žˆ๋‹ค.
@Embedded private Code code; @Embedded private Code teamCode;
Java
๋ณต์‚ฌ
โ€ข
Embedded ๊ฐ์ฒด๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ํ•ด๋‹น ๊ฐ์ฒด๋ฅผ ์—ฌ๋Ÿฌ๋ฒˆ ์‚ฌ์šฉํ•˜๋ฉด column ๋ช…์ด ์ค‘๋ณต์œผ๋กœ ๋“ค์–ด๊ฐˆ ์ˆ˜ ์žˆ๋‹ค.
โ€ข
Code ๊ฐ์ฒด ๋‚ด๋ถ€์˜ ๋ณ€์ˆ˜ ๋ช…์€ value ๋ผ์„œ code column ๊ณผ teamCode column ์— ๊ณตํ†ต์ ์œผ๋กœ ์ ์šฉ๋˜์–ด ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒ
@Embedded @AttributeOverride(name = "code", column = @Column(name = "code", nullable = false) private Code code; @Embedded @AttributeOverride(name = "code", column = @Column(name = "team_code", nullable = false) private Code teamCode;
Java
๋ณต์‚ฌ

@MappedSuperclass

โ€ข
๋ถ€๋ชจ ํด๋ž˜์Šค๊ฐ€ ์—”ํ‹ฐํ‹ฐ๊ฐ€ ์•„๋‹ ๋•Œ ์ƒ์†์„ ํ•ด์ฃผ์–ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ
โ€ข
๋ณดํ†ต BaseEntity ๋ผ๋Š” ํด๋ž˜์Šค๋กœ ์‚ฌ์šฉ