#84 Work on data layer

This commit is contained in:
Ilkka Seppala 2015-08-09 15:00:32 +03:00
parent d1bc28bb22
commit a44f32a1e0
3 changed files with 78 additions and 0 deletions

View 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<>();
}
}

View 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;
}
}

View 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;
}
}