0

In my Product class, two entities are relataded My model

@Entity
@Table(name= "products")
@SecondaryTable(name = "tb_components", pkJoinColumns = @PrimaryKeyJoinColumn(name = "products_id"))
public class Product {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private long id;
    
    @JoinColumn(name = "name")
    @Size(max=255)
    @JsonIgnoreProperties(value="child_prd")
    private String name;
    
    @ManyToOne
    @JsonIgnoreProperties("child_prd")
    private Product product;
    
    
    @Column(name = "child_prd", table = "tb_compponents")
    @OneToMany(mappedBy = "product", cascade = CascadeType.ALL)
    @JsonIgnoreProperties(value="product")
    private List<Product> child_prd;

And when I try to post(in postman or any app) a new product with products related to it, it shows me this error with bad request

"message": "JSON parse error: Cannot invoke \"com.fasterxml.jackson.databind.JsonDeserializer.getObjectIdReader()\" because \"valueDes\" is null; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Cannot invoke \"com.fasterxml.jackson.databind.JsonDeserializer.getObjectIdReader()\" because \"valueDes\" is null (through reference chain: br.org.restaurante.model.Product[\"child_prd\"]->java.util.ArrayList[0]->br.org.restaurante.model.Product[\"child_prd\"])",
    "path": "/produtos"
Massacote
  • 1
  • 1
  • possible duplicate https://stackoverflow.com/questions/66832175/json-parse-error-cannot-invoke-com-fasterxml-jackson-databind-jsondeserialize – J Asgarov Jan 29 '22 at 19:03
  • possibility of duplicate with https://stackoverflow.com/questions/66832175/json-parse-error-cannot-invoke-com-fasterxml-jackson-databind-jsondeserialize – Saman Salehi Feb 08 '22 at 07:09

0 Answers0