선이데이 2022. 5. 3. 22:05

products 테이블 생성

- DECIMAL(8,2) : 8자리 소수점 2자리 

- TIMESTAMP : 날짜 + 시간 (숫자형),자동으로 현날짜 입력 ↔  DATETIME 문자형, 직접입력

 

@Entity
@Table(name = "products")
@Data
public class Product {
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int id;
	
	private String name;
	private String slug;
	private String description;
	private String image;
	private String price;
	
	@Column(name = "category_id")
	private String categoryId;
	
	@Column(name = "created_at")
   	@CreationTimestamp
	private LocalDateTime createAt;
	
	@Column(name = "updated_at")
    	@UpdateTimestamp
	private LocalDateTime updateAt;
	
}

- LocalDate : 날짜만 2019-11-12
- LocalTime 시간만 18:32:17
- LocalDateTime 날짜 + 시간 2019-11-12T16:23:53

 

 

- 날짜를 자동생성하는 어노테이션

insert할때
@CreationTimestamp

update할때(수정)
@UpdateTimestamp

 

반응형
LIST