01: package example;
02:
03: import javax.persistence.*;
04: import java.util.Calendar;
05:
06: @Entity
07: @Table(name="recipes")
08: public class Recipe {
09: @Id
10: @GeneratedValue
11: private int id;
12:
13: @ManyToOne(optional=false)
14: @JoinColumn(name="category_id")
15: private Category category;
16:
17: @Column(unique=true,nullable=false)
18: private String title;
19:
20: private String description;
21:
22: @Column(nullable=false)
23: private Calendar date;
24:
25: @Lob
26: private String instructions;
27:
28: public Recipe() {
29: date = Calendar.getInstance();
30: }
31:
32: public Category getCategory() {
33: return category;
34: }
35:
36: public void setCategory(Category category) {
37: this .category = category;
38: }
39:
40: public Calendar getDate() {
41: return date;
42: }
43:
44: public void setDate(Calendar date) {
45: this .date = date;
46: }
47:
48: public String getDescription() {
49: return description;
50: }
51:
52: public void setDescription(String description) {
53: this .description = description;
54: }
55:
56: public int getId() {
57: return id;
58: }
59:
60: public void setId(int id) {
61: this .id = id;
62: }
63:
64: public String getInstructions() {
65: return instructions;
66: }
67:
68: public void setInstructions(String instructions) {
69: this .instructions = instructions;
70: }
71:
72: public String getTitle() {
73: return title;
74: }
75:
76: public void setTitle(String title) {
77: this .title = title;
78: }
79:
80: public String toString() {
81: return getClass().getSimpleName() + "[id=" + id + " title="
82: + title + "]";
83: }
84: }
|