Skip to content

Instantly share code, notes, and snippets.

@paulouskunda
Created March 15, 2023 08:41
Show Gist options
  • Save paulouskunda/7c91ce4a90cd7dec2b100a88d8fdd507 to your computer and use it in GitHub Desktop.
Save paulouskunda/7c91ce4a90cd7dec2b100a88d8fdd507 to your computer and use it in GitHub Desktop.
Recipe Entities
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonProperty
import com.paul.data.Ingredients
import org.hibernate.annotations.CreationTimestamp
import java.util.*
import javax.persistence.*
@Entity
@Table(name ="ingredients")
data class IngredientsEntity (
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
var ingredientsId: Int? = null,
@ManyToOne
@JoinColumn(name = "recipeId")
@JsonIgnore
var recipe: RecipeEntity? = null,
@CreationTimestamp
var createdAt: Date? = null,
var ingredientsDetail: String? = null
)
import com.fasterxml.jackson.annotation.JsonIgnore
import org.hibernate.annotations.CreationTimestamp
import java.util.*
import javax.persistence.*
@Entity
@Table(name ="instructions")
data class InstructionsEntity (
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@JsonIgnore
var instructionsId: Int? = null,
@ManyToOne
@JoinColumn(name = "recipeId")
@JsonIgnore
var recipeKey: RecipeEntity? = null,
@CreationTimestamp
@JsonIgnore
var createdAt: Date? = null,
var instructionDetails: String? = null
)
import com.fasterxml.jackson.annotation.JsonProperty
import org.hibernate.annotations.CreationTimestamp
import java.util.Date
import javax.persistence.*
import javax.xml.stream.events.ProcessingInstruction
@Entity
@Table(name ="recipe")
data class RecipeEntity (
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
var recipeId: Int? = null,
var recipeName: String? = null,
var recipeInstructions: String? = null,
var recipeImage: String? = null,
@CreationTimestamp
var createdAt: Date? = null,
@OneToMany(mappedBy = "recipe") var ingredientsEntity: List<IngredientsEntity>? = null,
@OneToMany(mappedBy = "recipeKey") var instructionsEntity: List<InstructionsEntity>? = null
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment