#84 Work on data layer
This commit is contained in:
parent
d1bc28bb22
commit
a44f32a1e0
28
layers/src/main/java/com/iluwatar/layers/Cake.java
Normal file
28
layers/src/main/java/com/iluwatar/layers/Cake.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package com.iluwatar.layers;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Cake {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@OneToMany
|
||||||
|
private List<CakeLayer> layers;
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
private CakeTopping topping;
|
||||||
|
|
||||||
|
public Cake() {
|
||||||
|
layers = new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
25
layers/src/main/java/com/iluwatar/layers/CakeLayer.java
Normal file
25
layers/src/main/java/com/iluwatar/layers/CakeLayer.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package com.iluwatar.layers;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class CakeLayer {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private int calories;
|
||||||
|
|
||||||
|
public CakeLayer() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public CakeLayer(String name, int calories) {
|
||||||
|
this.name = name;
|
||||||
|
this.calories = calories;
|
||||||
|
}
|
||||||
|
}
|
25
layers/src/main/java/com/iluwatar/layers/CakeTopping.java
Normal file
25
layers/src/main/java/com/iluwatar/layers/CakeTopping.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package com.iluwatar.layers;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class CakeTopping {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private int calories;
|
||||||
|
|
||||||
|
public CakeTopping() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public CakeTopping(String name, int calories) {
|
||||||
|
this.name = name;
|
||||||
|
this.calories = calories;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user