forked from springframeworkguru/spring5-recipe-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes Adicionar os Objetos Domain com modelo de relação 1 pra 1 spri…
- Loading branch information
Showing
2 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package guru.springframework.domain; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.Lob; | ||
import javax.persistence.OneToOne; | ||
|
||
@Entity | ||
public class Notes { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@OneToOne | ||
private Recipe recipe; | ||
|
||
@Lob | ||
private String recipeNotes; | ||
|
||
|
||
public Long getId() { | ||
return this.id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public Recipe getRecipe() { | ||
return this.recipe; | ||
} | ||
|
||
public void setRecipe(Recipe recipe) { | ||
this.recipe = recipe; | ||
} | ||
|
||
public String getRecipeNotes() { | ||
return this.recipeNotes; | ||
} | ||
|
||
public void setRecipeNotes(String recipeNotes) { | ||
this.recipeNotes = recipeNotes; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package guru.springframework.domain; | ||
|
||
import javax.persistence.CascadeType; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.Lob; | ||
import javax.persistence.OneToOne; | ||
|
||
@Entity | ||
public class Recipe { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String description; | ||
private Integer prepTime; | ||
private Integer cookTime; | ||
private Integer servings; | ||
private String source; | ||
private String url; | ||
private String directions; | ||
//todo add | ||
|
||
@Lob | ||
private Byte[] image; | ||
|
||
@OneToOne(cascade = CascadeType.ALL) | ||
private Notes notes; | ||
|
||
|
||
public Long getId() { | ||
return this.id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getDescription() { | ||
return this.description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
public Integer getPrepTime() { | ||
return this.prepTime; | ||
} | ||
|
||
public void setPrepTime(Integer prepTime) { | ||
this.prepTime = prepTime; | ||
} | ||
|
||
public Integer getCookTime() { | ||
return this.cookTime; | ||
} | ||
|
||
public void setCookTime(Integer cookTime) { | ||
this.cookTime = cookTime; | ||
} | ||
|
||
public Integer getServings() { | ||
return this.servings; | ||
} | ||
|
||
public void setServings(Integer servings) { | ||
this.servings = servings; | ||
} | ||
|
||
public String getSource() { | ||
return this.source; | ||
} | ||
|
||
public void setSource(String source) { | ||
this.source = source; | ||
} | ||
|
||
public String getUrl() { | ||
return this.url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
|
||
public String getDirections() { | ||
return this.directions; | ||
} | ||
|
||
public void setDirections(String directions) { | ||
this.directions = directions; | ||
} | ||
|
||
public Byte[] getImage() { | ||
return this.image; | ||
} | ||
|
||
public void setImage(Byte[] image) { | ||
this.image = image; | ||
} | ||
|
||
public Notes getNotes() { | ||
return this.notes; | ||
} | ||
|
||
public void setNotes(Notes notes) { | ||
this.notes = notes; | ||
} | ||
|
||
|
||
} |