如何从JSON发送Java Long值

I'm trying to send a POST request to an Spring RestController with a request body. In the object there is a Long value but it is not arriving to the endpoint with the other parameters. The class used as @RequestBody is this one:

@Entity
public class Curso {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long id;
    @Column(name = "titulo")
    private String titulo;
    @Column(name = "nivel")
    private String nivel;
    @Column(name = "nhoras")
    private String nhoras;
    @Column(name = "profesorid")
    private Long profesorid;
    [...]
    public Long getProfesorid() {
        return profesorid;
    }
    public void setProfesorid(Long profesor) {
        this.profesorid = profesorid;
    }
}

The endpoint in the class annotated with @RestController, is this:

    @RequestMapping(value = "/crear-curso", method = RequestMethod.POST)
    public void addCurso(@RequestBody Curso curso) {
        cursoService.addCurso(curso);
    }

这是我在POST请求主体中使用的JSON:

{
    "titulo": "Git",
    "nivel": "Intermedio",
    "nhoras": "12",
    "profesorid": 1581068174
}

All the other parameters are arriving correctly and the object arrives to the database, but with the profesorid with null value. I stopped the execution y this addCurso method and the value of profesorid is null. The id value is not being sent in the request because it is setted before saving in the database. Please, anyone can help me and say what is failing here? Many thanks in advance.

评论