File tree Expand file tree Collapse file tree
src/main/java/ru/javawebinar/topjava/model Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package ru .javawebinar .topjava .model ;
22
3- import javax .persistence .FetchType ;
4- import javax .persistence .ManyToOne ;
3+ import org .hibernate .validator .constraints .NotBlank ;
4+ import org .hibernate .validator .constraints .Range ;
5+
6+ import javax .persistence .*;
57import java .time .LocalDate ;
68import java .time .LocalDateTime ;
79import java .time .LocalTime ;
1012 * GKislin
1113 * 11.01.2015.
1214 */
15+ @ Entity
16+ @ Table (name = "meals" )
1317public class Meal extends BaseEntity {
18+ @ Column (name = "date_time" , nullable = false , columnDefinition = "timestamp default now()" )
19+ @ NotBlank
1420 private LocalDateTime dateTime ;
1521
22+ @ Column (name = "description" , nullable = false )
23+ @ NotBlank
1624 private String description ;
1725
26+ @ Column (name = "calories" , nullable = false )
27+ @ NotBlank
28+ @ Range (min = 10 , max = 10000 )
1829 private int calories ;
1930
20- @ ManyToOne (fetch = FetchType .LAZY )
31+ @ ManyToOne (fetch = FetchType .LAZY , cascade = {CascadeType .REMOVE })
32+ @ JoinColumn (name = "user_id" , nullable = false )
2133 private User user ;
2234
2335 public Meal () {
You can’t perform that action at this time.
0 commit comments