Commit 90f7865c by Patryk Czarnik

poprawki dot eksportu JSON, m.in. @JsonIgnore

parent cfe8a578
......@@ -7,6 +7,8 @@ import jakarta.validation.constraints.Pattern;
import java.util.LinkedHashSet;
import java.util.Set;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity
@Table(name = "customers")
public class Customer {
......@@ -32,6 +34,9 @@ public class Customer {
private String city;
@OneToMany(mappedBy = "customer")
@JsonIgnore
// W danych klienta zwracanych w JSONie nie będzie listy zamówień.
// Można by pomyśleć o stworzeniu dwóch wersji tej klasy - jedna z zamówieniami, jedna bez.
private Set<Order> orders = new LinkedHashSet<>();
public String getCustomerEmail() {
......
......@@ -16,7 +16,7 @@ public class Order {
@Column(name = "order_id", nullable = false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@ManyToOne( optional = false)
@JoinColumn(name = "customer_email", nullable = false)
private Customer customer;
......
......@@ -5,6 +5,8 @@ import jakarta.validation.constraints.Min;
import org.hibernate.annotations.ColumnDefault;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.math.BigDecimal;
@Entity
......@@ -16,6 +18,7 @@ public class OrderProduct {
@MapsId("orderId")
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "order_id", nullable = false)
@JsonIgnore
private Order order;
@MapsId("productId")
......
......@@ -6,4 +6,6 @@ spring.datasource.url=jdbc:postgresql://localhost/sklep
spring.datasource.username=alx
spring.datasource.password=abc123
spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false
alx.photo_dir=/home/patryk/sklep/foto
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment