@AssocicationOverride
@MappedSuperclass๋ฅผ ํตํด ์์ ๋ฐ์ ๊ฒฝ์ฐ๋ @Embedded๋ฅผ ํตํด ์์๋ฐ์ ํ๋ ์ค,
์ฐ๊ด๊ด๊ณ๋ฅผ ์ฌ์ ์ํ์ฌ ์ฌ์ฉํ๊ณ ์ถ์ ๊ฒฝ์ฐ์ ์ฌ์ฉํฉ๋๋ค.
@AssocicationOverride ํน์ @AssocicationOverrides๋ฅผ ์ฌ์ฉํ ์ ์์ผ๋ฉฐ, ์ฌ์ฉ ๋ฐฉ๋ฒ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
@AssociationOverride(name="๋ถ๋ชจ ํ๋๋ช ", joinColumns=@JoinColumn(name="์ฌ์ ์ํ FK ์ปฌ๋ผ๋ช "))
@MappedSuperclass
public class Employee {
...
@ManyToOne
protected Address address;
...
}
@Entity
@AssociationOverride(name="address", joinColumns=@JoinColumn(name="ADDR_ID"))
// address field mapping overridden to ADDR_ID foreign key
public class PartTimeEmployee extends Employee {
...
}
Reference
[Annotation] @MappedSuperclass
์ด๋ ธํ ์ด์ ์ค๋ช ๋งคํ ์ ๋ณด๊ฐ ์์๋๋ ์ํฐํฐ์ ์ ์ฉ๋๋ ํด๋์ค๋ฅผ ์ง์ ๋งคํ๋ ์์ํด๋์ค๋ ๋ณ๋์ ํ ์ด๋ธ์ด ์๋ค. @MappedSuperclass๊ฐ ์ง์ ๋ ํด๋์ค๋ Entity์ ๋์ผํ ๋ฐฉ๋ฒ์ผ๋ก ๋งคํ๋ ์ ์๋ค
seokr.tistory.com
AssociationOverride (Java(TM) EE 7 Specification APIs)
Used to override a mapping for an entity relationship. May be applied to an entity that extends a mapped superclass to override a relationship mapping defined by the mapped superclass. If not specified, the association is mapped the same as in the original
docs.oracle.com
์๋ฐ ORM ํ์ค JPA ํ๋ก๊ทธ๋๋ฐ - ๊ธฐ๋ณธํธ - ์ธํ๋ฐ | ๊ฐ์
JPA๋ฅผ ์ฒ์ ์ ํ๊ฑฐ๋, ์ค๋ฌด์์ JPA๋ฅผ ์ฌ์ฉํ์ง๋ง ๊ธฐ๋ณธ ์ด๋ก ์ด ๋ถ์กฑํ์ ๋ถ๋ค์ด JPA์ ๊ธฐ๋ณธ ์ด๋ก ์ ํํํ๊ฒ ํ์ตํด์ ์ด๋ณด์๋ ์ค๋ฌด์์ ์์ ์๊ฒ JPA๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค., ๋ณธ ๊ฐ์๋ ์๋ฐ ๋ฐฑ์
www.inflearn.com
[์๋ฐ ORM ํ์ค JPA ํ๋ก๊ทธ๋๋ฐ - ๊น์ํ]
'๐๏ธ Spring > JPA' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JPA] ์ฆ์ ๋ก๋ฉ๊ณผ ์ง์ฐ ๋ก๋ฉ ( + PersistentBag) (0) | 2021.12.15 |
---|---|
[JPA] JPA์์์ ํ๋ก์ (0) | 2021.12.15 |
[JPA] ํ๋์ ์ปฌ๋ผ ๋งคํ - @Embedded (์๋ฒ ๋๋ ํ์ ๋งคํ) (0) | 2021.12.15 |
[JPA] @MappedSuperclass (0) | 2021.12.15 |
[JPA] ์์๊ด๊ณ ๋งคํํ๋ ๋ฐฉ๋ฒ (0) | 2021.12.15 |