I'm using jpa and I have these two entities:
@Entity
@JsonIdentityInfo(
generator = ObjectIdGenerators.PropertyGenerator.class,
property = "id")
public class Categoria implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@NotNull
private int id;
private String tipo;
@JsonBackReference
@OneToMany(mappedBy = "categoria_id")
private List<Post> categoria_post;
}
@Entity
@JsonIdentityInfo(
generator = ObjectIdGenerators.PropertyGenerator.class,
property = "id")
public class Post implements Serializable {
@Id
@GeneratedValue(strategy =GenerationType.IDENTITY)
private int id;
@NotNull
private String titulo;
@NotNull
@JsonManagedReference
@ManyToOne
private Categoria categoria_id;
@NotNull
private String descricao;
private String img;
@ManyToOne
private Usuario post_usuario;
private int likes;
}
When I make a post to persist an object in the database, I get this exception:
javax.servlet.ServletException: javax.ws.rs.ProcessingException: Error deserializing object from entity stream. root cause
javax.ws.rs.ProcessingException: Error deserializing object from entity stream. root cause
javax.json.bind.JsonbException: Error deserialize JSON value into type: class com.emerich.model.Category.