-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathFollow.java
More file actions
33 lines (27 loc) · 883 Bytes
/
Follow.java
File metadata and controls
33 lines (27 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.example.devSns.domain;
import jakarta.persistence.*;
import lombok.*;
@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(
name = "follow",
uniqueConstraints = @UniqueConstraint(columnNames = {"follower_id", "following_id"})
)
public class Follow {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
// 나를 기준으로: 내가 팔로우 하는 사람
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "follower_id", nullable = false)
private Member follower;
// 내가 팔로우 당하는 사람
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "following_id", nullable = false)
private Member following;
@Builder
private Follow(Member follower, Member following) {
this.follower = follower;
this.following = following;
}
}