Skip to content

Commit

Permalink
Closes Adicionar os Objetos Domain com modelo de relação 1 pra 1 spri…
Browse files Browse the repository at this point in the history
  • Loading branch information
MGMAGNOJ committed Feb 26, 2021
1 parent 75aeded commit 55ba9e6
Show file tree
Hide file tree
Showing 2 changed files with 164 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/main/java/guru/springframework/domain/Notes.java
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;
}


}
115 changes: 115 additions & 0 deletions src/main/java/guru/springframework/domain/Recipe.java
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;
}


}

0 comments on commit 55ba9e6

Please sign in to comment.