File tree Expand file tree Collapse file tree 3 files changed +31
-9
lines changed
src/main/java/org/soujava/samples/mongodb/products Expand file tree Collapse file tree 3 files changed +31
-9
lines changed Original file line number Diff line number Diff line change 55import jakarta .nosql .Embeddable ;
66import org .soujava .samples .mongodb .products .infra .FieldVisibilityStrategy ;
77
8+
89@ Embeddable (Embeddable .EmbeddableType .GROUPING )
910@ JsonbVisibility (FieldVisibilityStrategy .class )
10- public class Manufacturer {
11-
12- @ Column
13- private String name ;
14-
15- @ Column
16- private String address ;
11+ public record Manufacturer (@ Column String name , @ Column String address , @ Column String contactNumber ) {
1712
18- @ Column
19- private String contactNumber ;
2013}
Original file line number Diff line number Diff line change 99import org .soujava .samples .mongodb .products .infra .FieldVisibilityStrategy ;
1010
1111import java .util .List ;
12+ import java .util .Objects ;
1213import java .util .Set ;
1314
1415@ Entity
@@ -30,4 +31,29 @@ public class Product {
3031
3132 @ Column
3233 private Set <Category > categories ;
34+
35+ @ Override
36+ public boolean equals (Object o ) {
37+ if (o == null || getClass () != o .getClass ()) {
38+ return false ;
39+ }
40+ Product product = (Product ) o ;
41+ return Objects .equals (id , product .id );
42+ }
43+
44+ @ Override
45+ public int hashCode () {
46+ return Objects .hashCode (id );
47+ }
48+
49+ @ Override
50+ public String toString () {
51+ return "Product{" +
52+ "id='" + id + '\'' +
53+ ", name='" + name + '\'' +
54+ ", manufacturer=" + manufacturer +
55+ ", tags=" + tags +
56+ ", categories=" + categories +
57+ '}' ;
58+ }
3359}
Original file line number Diff line number Diff line change 44import jakarta .data .Sort ;
55import jakarta .data .page .PageRequest ;
66import jakarta .enterprise .context .ApplicationScoped ;
7+ import jakarta .inject .Inject ;
78import jakarta .ws .rs .DELETE ;
89import jakarta .ws .rs .DefaultValue ;
910import jakarta .ws .rs .GET ;
@@ -27,6 +28,7 @@ public class ProductResource {
2728
2829 private final ProductRepository repository ;
2930
31+ @ Inject
3032 public ProductResource (ProductRepository repository ) {
3133 this .repository = repository ;
3234 }
@@ -47,6 +49,7 @@ public List<Product> get(
4749
4850 @ POST
4951 public Product insert (Product product ) {
52+ LOGGER .info ("The product will be saved: " + product );
5053 return repository .save (product );
5154 }
5255
You can’t perform that action at this time.
0 commit comments