Skip to content

Commit 55ba9e6

Browse files
committed
Closes Adicionar os Objetos Domain com modelo de relação 1 pra 1 springframeworkguru#104
1 parent 75aeded commit 55ba9e6

File tree

2 files changed

+164
-0
lines changed

2 files changed

+164
-0
lines changed

Diff for: src/main/java/guru/springframework/domain/Notes.java

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package guru.springframework.domain;
2+
3+
import javax.persistence.Entity;
4+
import javax.persistence.GeneratedValue;
5+
import javax.persistence.GenerationType;
6+
import javax.persistence.Id;
7+
import javax.persistence.Lob;
8+
import javax.persistence.OneToOne;
9+
10+
@Entity
11+
public class Notes {
12+
13+
@Id
14+
@GeneratedValue(strategy = GenerationType.IDENTITY)
15+
private Long id;
16+
17+
@OneToOne
18+
private Recipe recipe;
19+
20+
@Lob
21+
private String recipeNotes;
22+
23+
24+
public Long getId() {
25+
return this.id;
26+
}
27+
28+
public void setId(Long id) {
29+
this.id = id;
30+
}
31+
32+
public Recipe getRecipe() {
33+
return this.recipe;
34+
}
35+
36+
public void setRecipe(Recipe recipe) {
37+
this.recipe = recipe;
38+
}
39+
40+
public String getRecipeNotes() {
41+
return this.recipeNotes;
42+
}
43+
44+
public void setRecipeNotes(String recipeNotes) {
45+
this.recipeNotes = recipeNotes;
46+
}
47+
48+
49+
}
+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
package guru.springframework.domain;
2+
3+
import javax.persistence.CascadeType;
4+
import javax.persistence.Entity;
5+
import javax.persistence.GeneratedValue;
6+
import javax.persistence.GenerationType;
7+
import javax.persistence.Id;
8+
import javax.persistence.Lob;
9+
import javax.persistence.OneToOne;
10+
11+
@Entity
12+
public class Recipe {
13+
14+
@Id
15+
@GeneratedValue(strategy = GenerationType.IDENTITY)
16+
private Long id;
17+
18+
private String description;
19+
private Integer prepTime;
20+
private Integer cookTime;
21+
private Integer servings;
22+
private String source;
23+
private String url;
24+
private String directions;
25+
//todo add
26+
27+
@Lob
28+
private Byte[] image;
29+
30+
@OneToOne(cascade = CascadeType.ALL)
31+
private Notes notes;
32+
33+
34+
public Long getId() {
35+
return this.id;
36+
}
37+
38+
public void setId(Long id) {
39+
this.id = id;
40+
}
41+
42+
public String getDescription() {
43+
return this.description;
44+
}
45+
46+
public void setDescription(String description) {
47+
this.description = description;
48+
}
49+
50+
public Integer getPrepTime() {
51+
return this.prepTime;
52+
}
53+
54+
public void setPrepTime(Integer prepTime) {
55+
this.prepTime = prepTime;
56+
}
57+
58+
public Integer getCookTime() {
59+
return this.cookTime;
60+
}
61+
62+
public void setCookTime(Integer cookTime) {
63+
this.cookTime = cookTime;
64+
}
65+
66+
public Integer getServings() {
67+
return this.servings;
68+
}
69+
70+
public void setServings(Integer servings) {
71+
this.servings = servings;
72+
}
73+
74+
public String getSource() {
75+
return this.source;
76+
}
77+
78+
public void setSource(String source) {
79+
this.source = source;
80+
}
81+
82+
public String getUrl() {
83+
return this.url;
84+
}
85+
86+
public void setUrl(String url) {
87+
this.url = url;
88+
}
89+
90+
public String getDirections() {
91+
return this.directions;
92+
}
93+
94+
public void setDirections(String directions) {
95+
this.directions = directions;
96+
}
97+
98+
public Byte[] getImage() {
99+
return this.image;
100+
}
101+
102+
public void setImage(Byte[] image) {
103+
this.image = image;
104+
}
105+
106+
public Notes getNotes() {
107+
return this.notes;
108+
}
109+
110+
public void setNotes(Notes notes) {
111+
this.notes = notes;
112+
}
113+
114+
115+
}

0 commit comments

Comments
 (0)