File tree Expand file tree Collapse file tree 3 files changed +78
-0
lines changed
layers/src/main/java/com/iluwatar/layers Expand file tree Collapse file tree 3 files changed +78
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .iluwatar .layers ;
2+
3+ import java .util .ArrayList ;
4+ import java .util .List ;
5+
6+ import javax .persistence .Entity ;
7+ import javax .persistence .GeneratedValue ;
8+ import javax .persistence .Id ;
9+ import javax .persistence .OneToMany ;
10+ import javax .persistence .OneToOne ;
11+
12+ @ Entity
13+ public class Cake {
14+
15+ @ Id
16+ @ GeneratedValue
17+ private Long id ;
18+
19+ @ OneToMany
20+ private List <CakeLayer > layers ;
21+
22+ @ OneToOne
23+ private CakeTopping topping ;
24+
25+ public Cake () {
26+ layers = new ArrayList <>();
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ package com .iluwatar .layers ;
2+
3+ import javax .persistence .Entity ;
4+ import javax .persistence .GeneratedValue ;
5+ import javax .persistence .Id ;
6+
7+ @ Entity
8+ public class CakeLayer {
9+
10+ @ Id
11+ @ GeneratedValue
12+ private Long id ;
13+
14+ private String name ;
15+
16+ private int calories ;
17+
18+ public CakeLayer () {
19+ }
20+
21+ public CakeLayer (String name , int calories ) {
22+ this .name = name ;
23+ this .calories = calories ;
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ package com .iluwatar .layers ;
2+
3+ import javax .persistence .Entity ;
4+ import javax .persistence .GeneratedValue ;
5+ import javax .persistence .Id ;
6+
7+ @ Entity
8+ public class CakeTopping {
9+
10+ @ Id
11+ @ GeneratedValue
12+ private Long id ;
13+
14+ private String name ;
15+
16+ private int calories ;
17+
18+ public CakeTopping () {
19+ }
20+
21+ public CakeTopping (String name , int calories ) {
22+ this .name = name ;
23+ this .calories = calories ;
24+ }
25+ }
You can’t perform that action at this time.
0 commit comments