11-15 06:12
Recent Posts
Recent Comments
Tags
- Java
- ์คํฝ๋ ํ
- ํ๋ก๋ณด๋ ธ
- ์๋ฐ
- ์จ์ผ๋ํ
- ํ์ด์
- ์๋์ด๋ ธ
- ICT๋ฉํ ๋ง
- appetizer
- ์กํ๊ณ
- ์คํฝ์ค๋น
- ์ด๋ธ์
- ict๊ณต๋ชจ์
- Naver Cloud
- ICT
- ํ์ด์ฌ
- API๋ง์ผํ๋ ์ด์ค
- RaspberryPi
- SQL
- DATABASE
- DB
- JOBํ๊ณ
- linux
- mysql
- python
- Spring
- TSQL
- ํ์ด์๊ณต๋ชจ์
- API MarketPlace ๊ธ๋ก๋ฒ ์ํฌํฐ์ฆ
- ๋ฐ์ดํฐ๋ฒ ์ด์ค
- Today
- Total
miinsun
[JPA] ๋ณตํฉํค ์ค์ ๋ณธ๋ฌธ
๐ JPA ๋ณตํฉํค ์ค์ ํ๋ ๋ฐฉ๋ฒ
๋จผ์ PK ํด๋์ค๋ฅผ ๋ง๋ค์ด ์ค๋ค.
@Data
class UserLikePlacePK implements Serializable{
private String userId;
private int placeId;
}
๋ง๋ค์ด์ค PK ํด๋์ค๋ฅผ JPA ๋๋ฉ์ธ ํด๋์ค์ ์ ์ฉํด์ค๋ค.
@SuppressWarnings("serial")
@Entity
@Table(name="user_like_place")
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@IdClass(UserLikePlacePK.class)
public class UserLikePlace implements Serializable{
@Id
@Column(name = "user_id")
private String userId;
@Id
@Column(name = "place_id")
private int placeId;
@OneToOne
@JoinColumn(name="place_id", insertable = false, updatable = false)
private Place place;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone="Asia/Seoul")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@Transient
private String time;
}
'WebApp > Spring' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Comments