해당 필드가 엔티티 클래스의 기본 키 역할을 수행함을 나타낸다.
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class Person {
@Id
private Long id;
private String name;
private int age;
// Getters and Setters
}
엔티티 객체를 식별하는데 사용되는 고유값으로
기본키를 지정하면 JPA는 객체를 저장/조회할 때 식별할 수 있어 객체지향적인 방식으로
데이터베이스 테이블과 상호작용 할 수 있다.
'JAVA > JPA' 카테고리의 다른 글
Annotation - @Column (0) | 2023.06.25 |
---|---|
Annotation - @GeneratedValue (0) | 2023.06.25 |
Annotation - @Table (0) | 2023.06.25 |
Annotation - @Entity (0) | 2023.06.25 |
hibernate.dialect, hiberbate란? (0) | 2023.05.03 |