๋ฌธ์ ์ํฉ
Planner๊ฐ User๋ฅผ ์์๋ฐ๊ณ ์๊ณ , ๋ ๋ค์๊ฒ @Builder๋ฅผ ์ ์ธํ ์ํฉ
@SuppressWarnings("checkstyle:RegexpMultiline")
@NoArgsConstructor
@Getter
@Entity
public class Users extends BaseTimeEntity {
...
@Builder
public Users(String email, String nickname, String imageUrl, AuthProvider authProvider, String authProviderId) {
this.email = email;
this.nickname = nickname;
this.imageUrl = imageUrl;
this.authProvider = authProvider;
this.authProviderId = authProviderId;
this.state = UserEnum.NORMAL;
this.role = "USER";
this.blockCnt = 0;
this.reportCnt = 0;
}
}
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "dtype")
public class Planner extends Users {
...
@Builder
public Planner(String company, String position, String region) {
this.company = company;
this.position = position;
this.region = region;
}
}
์ด๋ ๊ฒ ์ ์ธํ๋๋ ๋์ ๋ฐํ ํ์ ์ด ๋ค๋ฅด๋ค๋ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค
builder() in .users.entity.Planner cannot hide builder() in.entity.Users
return typeentity.Planner.PlannerBuilder is not compatible with entity.Users.UsersBuilder
๋ฐ์ ์ด์
@Builder ๋ก ์ด๊ธฐํํ ๋, ์์ ํด๋์ค์์ ๋ถ๋ชจ ํด๋์ค์ ๋ฉค๋ฒ ๋ณ์๋ฅผ ๋ฐ๊ฒฌํ์ง ๋ชปํด ์ด๊ธฐํํ ์ ์์ด์ ๋ฐ์ํ๋ค
ํด๊ฒฐ ๋ฐฉ๋ฒ
@SuperBuilder๋ฅผ ์ด์ฉํด ๋ถ๋ชจ ๊ฐ์ฒด๋ฅผ ์์๋ฐ๋ ์์ ๊ฐ์ฒด์์๋ ๋ถ๋ชจ ๊ฐ์ฒด์ ํ๋๊ฐ์ ์ง์ ํ ์ ์๊ฒ ๋ฐ๊ฟ์ค๋ค
๊ฐ ์ํฐํฐ ์์ ํด๋น annotation์ ์ถ๊ฐํด์ฃผ๋ฉด ๋๋ค
@SuperBuilder
@NoArgsConstructor
@Getter
@Entity
public class Users extends BaseTimeEntity {
@SuperBuilder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "dtype")
public class Planner extends Users {
'๐ฅ ํ๋ก์ ํธ > ์จ๋ฉ๋ฉ์ดํธ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[์ค๋ฅ] Transactional์ ๋ฒ์์์ ๋ฒ์ด๋ dirty checking์ด ๋์ง ์๋ ๊ฒฝ์ฐ (0) | 2023.08.13 |
---|---|
[์ง์] ๋ฉ์๋ ์ฐธ์กฐ์ ์์ฑ์ ์ฐธ์กฐ (0) | 2023.07.28 |
[AWS S3] ๋ฒํท ์์ฑํ๊ธฐ (0) | 2023.07.13 |
[Github Hook] Jira ํฐ์ผ ๋ฒํธ ์ปค๋ฐ ๋ฉ์์ง ์๋ ์ถ๊ฐํ๊ธฐ (0) | 2023.06.29 |
0. ํ๋ก์ ํธ ์ธํ (0) | 2023.06.29 |
๋๊ธ