How to POST correctly to a bidirectional relationshipHow do I efficiently iterate over each entry in a Java Map?How do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?Wrong ordering in generated table in jpaHow to deserialize a list using GSON or another JSON library in Java?How do I convert a String to an int in Java?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?MappingJackson2HttpMessageConverter Can not find a (Map) Key deserializer for typeHibernate : Why FetchType.LAZY-annotated collection property eagerly loading?com.fasterxml.jackson.databind.JsonMappingException: Multiple back-reference properties with name 'defaultReference'

Is it right to use the ideas of non-winning designers in a design contest?

Is the interior of a Bag of Holding actually an extradimensional space?

What is the justification for Dirac's large numbers hypothesis?

Is there a neutral term for people who tend to avoid face-to-face or video/audio communication?

Project Euler Problem 45

Can taking my 1-week-old on a 6-7 hours journey in the car lead to medical complications?

How do I anonymously report the Establishment Clause being broken?

Mute single speaker?

Why does the seven segment display have decimal point at the right?

Types of tablet... a tablet secretion

Why would image resources loaded from different origins triggering HTTP authentication dialogs be harmful?

Pronunciation of "sincero" and "sinceramente"

What is the purpose of the rotating plate in front of the lock?

Examples where "thin + thin = nice and thick"

Male viewpoint in an erotic novel

Are there mathematical concepts that exist in the fourth dimension, but not in the third dimension?

How could a planet have one hemisphere way warmer than the other without the planet being tidally locked?

Can there be a unique planet visible each different month?

How do German speakers decide what should be on the left side of the verb?

How do I stop making people jump at home and at work?

Looking for the comic book where Spider-Man was [mistakenly] addressed as Super-Man

Why does 8 bit truecolor use only 2 bits for blue?

Existence of a Hölder-free space

Some questions about a series pass transistor & op amp voltage regulator



How to POST correctly to a bidirectional relationship


How do I efficiently iterate over each entry in a Java Map?How do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?Wrong ordering in generated table in jpaHow to deserialize a list using GSON or another JSON library in Java?How do I convert a String to an int in Java?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?MappingJackson2HttpMessageConverter Can not find a (Map) Key deserializer for typeHibernate : Why FetchType.LAZY-annotated collection property eagerly loading?com.fasterxml.jackson.databind.JsonMappingException: Multiple back-reference properties with name 'defaultReference'






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















So im implmenting an API using springboot, spring-data and Jackson, but im having some troubles when im trying to POST a request to an endpoint who have a Bidirection relationship of @OneToMany.



I dont have so much background so i need really help.



I have two Entities:



Partida



package lucas.duarte.jazz.model.bean;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.fasterxml.jackson.annotation.JsonProperty;

@Entity
public class Partida implements Serializable
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String timeA;
private String timeB;
private boolean visitante;
@OneToMany(mappedBy = "partida", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<Set> sets;


public List<Set> getSets()
return sets;


public void setSets(List<Set> sets)
this.sets = sets;


public Long getId()
return id;


public void setId(Long id)
this.id = id;


public String getTimeA()
return timeA;


// Mocado o valor pois o Time A sempre e a Sao Judas
public void setTimeA(String timeA)
this.timeA = timeA;


public String getTimeB()
return timeB;


public void setTimeB(String timeB)
this.timeB = timeB;


public boolean isVisitante()
return visitante;


public void setVisitante(boolean visitante)
this.visitante = visitante;






and SET



package lucas.duarte.jazz.model.bean;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

@Entity
@Table(name = "meu_set")
public class Set implements Serializable
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "ponto_a")
private long pontoA;
@Column(name = "ponto_b")
private long pontoB;
@Column(name = "set_finalizado")
private boolean setFinalizado;
@ManyToOne
@JoinColumn(name = "partida_id")
private Partida partida;

public Long getId()
return id;


public void setId(Long id)
this.id = id;


public long getPontoA()
return pontoA;


public void setPontoA(long pontoA)
this.pontoA = pontoA;


public long getPontoB()
return pontoB;


public void setPontoB(long pontoB)
this.pontoB = pontoB;


public boolean isSetFinalizado()
return setFinalizado;


public void setSetFinalizado(boolean setFinalizado)
this.setFinalizado = setFinalizado;


public Partida getPartida()
return partida;


public void setPartida(Partida partida)
this.partida = partida;






This is my SetControler



package lucas.duarte.jazz.controller;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.util.UriComponentsBuilder;

import lucas.duarte.jazz.model.bean.Set;
import lucas.duarte.jazz.model.service.SetService;

@Controller
@RequestMapping("/api")
public class SetController

private SetService setServ;

@RequestMapping(value = "/set/", method = RequestMethod.POST)
public ResponseEntity<?> salvarSet(@RequestBody Set set, UriComponentsBuilder ucBuilder)
System.out.println("Vou cadastrar um set vinculado a uma partida");
System.out.println(set.getPartida().getId());
setServ.salvarSet(set);
return new ResponseEntity(HttpStatus.CREATED);






When i POST to the URL, i get the following return




"timestamp": "2019-03-28T04:17:46.857+0000",
"status": 400,
"error": "Bad Request",
"message": "JSON parse error: Cannot construct instance of `lucas.duarte.jazz.model.bean.Partida` (although at least one Creator exists): no int/Int-argument constructor/factory method to deserialize from Number value (1); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `lucas.duarte.jazz.model.bean.Partida` (although at least one Creator exists): no int/Int-argument constructor/factory method to deserialize from Number value (1)n at [Source: (PushbackInputStream); line: 5, column: 14] (through reference chain: lucas.duarte.jazz.model.bean.Set["partida"])",
"path": "/api/set/"



I Already have a Partida inside my database, but i cannot POST to this method, need really help.










share|improve this question
























  • please define default constructor public Partida ()

    – Ved Prakash
    Mar 28 at 4:54












  • For deserialisation purposes Partida class must have a zero-arg constructor.

    – Ved Prakash
    Mar 28 at 4:57











  • Show the json body you're trying to send to this endpoint

    – k9yosh
    Mar 28 at 4:58











  • "pontoA" : 1, "pontoB" : 1, "setFinalizado" : "false", "partida_id" : 1 Json Body of my request

    – Lucas Duarte
    Mar 28 at 5:08











  • @LucasDuarte try This "partida_id": 1, "pontoA": 1, "pontoB": 1, "setFinalizado": "false"

    – Ved Prakash
    Mar 28 at 5:24

















0















So im implmenting an API using springboot, spring-data and Jackson, but im having some troubles when im trying to POST a request to an endpoint who have a Bidirection relationship of @OneToMany.



I dont have so much background so i need really help.



I have two Entities:



Partida



package lucas.duarte.jazz.model.bean;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.fasterxml.jackson.annotation.JsonProperty;

@Entity
public class Partida implements Serializable
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String timeA;
private String timeB;
private boolean visitante;
@OneToMany(mappedBy = "partida", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<Set> sets;


public List<Set> getSets()
return sets;


public void setSets(List<Set> sets)
this.sets = sets;


public Long getId()
return id;


public void setId(Long id)
this.id = id;


public String getTimeA()
return timeA;


// Mocado o valor pois o Time A sempre e a Sao Judas
public void setTimeA(String timeA)
this.timeA = timeA;


public String getTimeB()
return timeB;


public void setTimeB(String timeB)
this.timeB = timeB;


public boolean isVisitante()
return visitante;


public void setVisitante(boolean visitante)
this.visitante = visitante;






and SET



package lucas.duarte.jazz.model.bean;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

@Entity
@Table(name = "meu_set")
public class Set implements Serializable
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "ponto_a")
private long pontoA;
@Column(name = "ponto_b")
private long pontoB;
@Column(name = "set_finalizado")
private boolean setFinalizado;
@ManyToOne
@JoinColumn(name = "partida_id")
private Partida partida;

public Long getId()
return id;


public void setId(Long id)
this.id = id;


public long getPontoA()
return pontoA;


public void setPontoA(long pontoA)
this.pontoA = pontoA;


public long getPontoB()
return pontoB;


public void setPontoB(long pontoB)
this.pontoB = pontoB;


public boolean isSetFinalizado()
return setFinalizado;


public void setSetFinalizado(boolean setFinalizado)
this.setFinalizado = setFinalizado;


public Partida getPartida()
return partida;


public void setPartida(Partida partida)
this.partida = partida;






This is my SetControler



package lucas.duarte.jazz.controller;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.util.UriComponentsBuilder;

import lucas.duarte.jazz.model.bean.Set;
import lucas.duarte.jazz.model.service.SetService;

@Controller
@RequestMapping("/api")
public class SetController

private SetService setServ;

@RequestMapping(value = "/set/", method = RequestMethod.POST)
public ResponseEntity<?> salvarSet(@RequestBody Set set, UriComponentsBuilder ucBuilder)
System.out.println("Vou cadastrar um set vinculado a uma partida");
System.out.println(set.getPartida().getId());
setServ.salvarSet(set);
return new ResponseEntity(HttpStatus.CREATED);






When i POST to the URL, i get the following return




"timestamp": "2019-03-28T04:17:46.857+0000",
"status": 400,
"error": "Bad Request",
"message": "JSON parse error: Cannot construct instance of `lucas.duarte.jazz.model.bean.Partida` (although at least one Creator exists): no int/Int-argument constructor/factory method to deserialize from Number value (1); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `lucas.duarte.jazz.model.bean.Partida` (although at least one Creator exists): no int/Int-argument constructor/factory method to deserialize from Number value (1)n at [Source: (PushbackInputStream); line: 5, column: 14] (through reference chain: lucas.duarte.jazz.model.bean.Set["partida"])",
"path": "/api/set/"



I Already have a Partida inside my database, but i cannot POST to this method, need really help.










share|improve this question
























  • please define default constructor public Partida ()

    – Ved Prakash
    Mar 28 at 4:54












  • For deserialisation purposes Partida class must have a zero-arg constructor.

    – Ved Prakash
    Mar 28 at 4:57











  • Show the json body you're trying to send to this endpoint

    – k9yosh
    Mar 28 at 4:58











  • "pontoA" : 1, "pontoB" : 1, "setFinalizado" : "false", "partida_id" : 1 Json Body of my request

    – Lucas Duarte
    Mar 28 at 5:08











  • @LucasDuarte try This "partida_id": 1, "pontoA": 1, "pontoB": 1, "setFinalizado": "false"

    – Ved Prakash
    Mar 28 at 5:24













0












0








0








So im implmenting an API using springboot, spring-data and Jackson, but im having some troubles when im trying to POST a request to an endpoint who have a Bidirection relationship of @OneToMany.



I dont have so much background so i need really help.



I have two Entities:



Partida



package lucas.duarte.jazz.model.bean;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.fasterxml.jackson.annotation.JsonProperty;

@Entity
public class Partida implements Serializable
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String timeA;
private String timeB;
private boolean visitante;
@OneToMany(mappedBy = "partida", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<Set> sets;


public List<Set> getSets()
return sets;


public void setSets(List<Set> sets)
this.sets = sets;


public Long getId()
return id;


public void setId(Long id)
this.id = id;


public String getTimeA()
return timeA;


// Mocado o valor pois o Time A sempre e a Sao Judas
public void setTimeA(String timeA)
this.timeA = timeA;


public String getTimeB()
return timeB;


public void setTimeB(String timeB)
this.timeB = timeB;


public boolean isVisitante()
return visitante;


public void setVisitante(boolean visitante)
this.visitante = visitante;






and SET



package lucas.duarte.jazz.model.bean;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

@Entity
@Table(name = "meu_set")
public class Set implements Serializable
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "ponto_a")
private long pontoA;
@Column(name = "ponto_b")
private long pontoB;
@Column(name = "set_finalizado")
private boolean setFinalizado;
@ManyToOne
@JoinColumn(name = "partida_id")
private Partida partida;

public Long getId()
return id;


public void setId(Long id)
this.id = id;


public long getPontoA()
return pontoA;


public void setPontoA(long pontoA)
this.pontoA = pontoA;


public long getPontoB()
return pontoB;


public void setPontoB(long pontoB)
this.pontoB = pontoB;


public boolean isSetFinalizado()
return setFinalizado;


public void setSetFinalizado(boolean setFinalizado)
this.setFinalizado = setFinalizado;


public Partida getPartida()
return partida;


public void setPartida(Partida partida)
this.partida = partida;






This is my SetControler



package lucas.duarte.jazz.controller;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.util.UriComponentsBuilder;

import lucas.duarte.jazz.model.bean.Set;
import lucas.duarte.jazz.model.service.SetService;

@Controller
@RequestMapping("/api")
public class SetController

private SetService setServ;

@RequestMapping(value = "/set/", method = RequestMethod.POST)
public ResponseEntity<?> salvarSet(@RequestBody Set set, UriComponentsBuilder ucBuilder)
System.out.println("Vou cadastrar um set vinculado a uma partida");
System.out.println(set.getPartida().getId());
setServ.salvarSet(set);
return new ResponseEntity(HttpStatus.CREATED);






When i POST to the URL, i get the following return




"timestamp": "2019-03-28T04:17:46.857+0000",
"status": 400,
"error": "Bad Request",
"message": "JSON parse error: Cannot construct instance of `lucas.duarte.jazz.model.bean.Partida` (although at least one Creator exists): no int/Int-argument constructor/factory method to deserialize from Number value (1); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `lucas.duarte.jazz.model.bean.Partida` (although at least one Creator exists): no int/Int-argument constructor/factory method to deserialize from Number value (1)n at [Source: (PushbackInputStream); line: 5, column: 14] (through reference chain: lucas.duarte.jazz.model.bean.Set["partida"])",
"path": "/api/set/"



I Already have a Partida inside my database, but i cannot POST to this method, need really help.










share|improve this question














So im implmenting an API using springboot, spring-data and Jackson, but im having some troubles when im trying to POST a request to an endpoint who have a Bidirection relationship of @OneToMany.



I dont have so much background so i need really help.



I have two Entities:



Partida



package lucas.duarte.jazz.model.bean;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.fasterxml.jackson.annotation.JsonProperty;

@Entity
public class Partida implements Serializable
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String timeA;
private String timeB;
private boolean visitante;
@OneToMany(mappedBy = "partida", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<Set> sets;


public List<Set> getSets()
return sets;


public void setSets(List<Set> sets)
this.sets = sets;


public Long getId()
return id;


public void setId(Long id)
this.id = id;


public String getTimeA()
return timeA;


// Mocado o valor pois o Time A sempre e a Sao Judas
public void setTimeA(String timeA)
this.timeA = timeA;


public String getTimeB()
return timeB;


public void setTimeB(String timeB)
this.timeB = timeB;


public boolean isVisitante()
return visitante;


public void setVisitante(boolean visitante)
this.visitante = visitante;






and SET



package lucas.duarte.jazz.model.bean;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

@Entity
@Table(name = "meu_set")
public class Set implements Serializable
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "ponto_a")
private long pontoA;
@Column(name = "ponto_b")
private long pontoB;
@Column(name = "set_finalizado")
private boolean setFinalizado;
@ManyToOne
@JoinColumn(name = "partida_id")
private Partida partida;

public Long getId()
return id;


public void setId(Long id)
this.id = id;


public long getPontoA()
return pontoA;


public void setPontoA(long pontoA)
this.pontoA = pontoA;


public long getPontoB()
return pontoB;


public void setPontoB(long pontoB)
this.pontoB = pontoB;


public boolean isSetFinalizado()
return setFinalizado;


public void setSetFinalizado(boolean setFinalizado)
this.setFinalizado = setFinalizado;


public Partida getPartida()
return partida;


public void setPartida(Partida partida)
this.partida = partida;






This is my SetControler



package lucas.duarte.jazz.controller;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.util.UriComponentsBuilder;

import lucas.duarte.jazz.model.bean.Set;
import lucas.duarte.jazz.model.service.SetService;

@Controller
@RequestMapping("/api")
public class SetController

private SetService setServ;

@RequestMapping(value = "/set/", method = RequestMethod.POST)
public ResponseEntity<?> salvarSet(@RequestBody Set set, UriComponentsBuilder ucBuilder)
System.out.println("Vou cadastrar um set vinculado a uma partida");
System.out.println(set.getPartida().getId());
setServ.salvarSet(set);
return new ResponseEntity(HttpStatus.CREATED);






When i POST to the URL, i get the following return




"timestamp": "2019-03-28T04:17:46.857+0000",
"status": 400,
"error": "Bad Request",
"message": "JSON parse error: Cannot construct instance of `lucas.duarte.jazz.model.bean.Partida` (although at least one Creator exists): no int/Int-argument constructor/factory method to deserialize from Number value (1); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `lucas.duarte.jazz.model.bean.Partida` (although at least one Creator exists): no int/Int-argument constructor/factory method to deserialize from Number value (1)n at [Source: (PushbackInputStream); line: 5, column: 14] (through reference chain: lucas.duarte.jazz.model.bean.Set["partida"])",
"path": "/api/set/"



I Already have a Partida inside my database, but i cannot POST to this method, need really help.







java spring-boot spring-mvc jackson spring-data






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 28 at 4:47









Lucas DuarteLucas Duarte

32 bronze badges




32 bronze badges















  • please define default constructor public Partida ()

    – Ved Prakash
    Mar 28 at 4:54












  • For deserialisation purposes Partida class must have a zero-arg constructor.

    – Ved Prakash
    Mar 28 at 4:57











  • Show the json body you're trying to send to this endpoint

    – k9yosh
    Mar 28 at 4:58











  • "pontoA" : 1, "pontoB" : 1, "setFinalizado" : "false", "partida_id" : 1 Json Body of my request

    – Lucas Duarte
    Mar 28 at 5:08











  • @LucasDuarte try This "partida_id": 1, "pontoA": 1, "pontoB": 1, "setFinalizado": "false"

    – Ved Prakash
    Mar 28 at 5:24

















  • please define default constructor public Partida ()

    – Ved Prakash
    Mar 28 at 4:54












  • For deserialisation purposes Partida class must have a zero-arg constructor.

    – Ved Prakash
    Mar 28 at 4:57











  • Show the json body you're trying to send to this endpoint

    – k9yosh
    Mar 28 at 4:58











  • "pontoA" : 1, "pontoB" : 1, "setFinalizado" : "false", "partida_id" : 1 Json Body of my request

    – Lucas Duarte
    Mar 28 at 5:08











  • @LucasDuarte try This "partida_id": 1, "pontoA": 1, "pontoB": 1, "setFinalizado": "false"

    – Ved Prakash
    Mar 28 at 5:24
















please define default constructor public Partida ()

– Ved Prakash
Mar 28 at 4:54






please define default constructor public Partida ()

– Ved Prakash
Mar 28 at 4:54














For deserialisation purposes Partida class must have a zero-arg constructor.

– Ved Prakash
Mar 28 at 4:57





For deserialisation purposes Partida class must have a zero-arg constructor.

– Ved Prakash
Mar 28 at 4:57













Show the json body you're trying to send to this endpoint

– k9yosh
Mar 28 at 4:58





Show the json body you're trying to send to this endpoint

– k9yosh
Mar 28 at 4:58













"pontoA" : 1, "pontoB" : 1, "setFinalizado" : "false", "partida_id" : 1 Json Body of my request

– Lucas Duarte
Mar 28 at 5:08





"pontoA" : 1, "pontoB" : 1, "setFinalizado" : "false", "partida_id" : 1 Json Body of my request

– Lucas Duarte
Mar 28 at 5:08













@LucasDuarte try This "partida_id": 1, "pontoA": 1, "pontoB": 1, "setFinalizado": "false"

– Ved Prakash
Mar 28 at 5:24





@LucasDuarte try This "partida_id": 1, "pontoA": 1, "pontoB": 1, "setFinalizado": "false"

– Ved Prakash
Mar 28 at 5:24












2 Answers
2






active

oldest

votes


















0
















This issue has nothing to do with JPA bi-directional mapping. Its raising error at the time of de serializing.

Partida -> should have zero argument constructor



Request payload should have "partida":"id":123 in order to populate partida object property.






share|improve this answer

























  • When i tried this, i got the follow 2019-03-28 02:48:17.679 ERROR 8180 --- [nio-5888-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

    – Lucas Duarte
    Mar 28 at 5:49











  • You were right, just the way who i pass the JSON, and the null pointer exeception was because i forgot the @Autowired annotation tho inject the dependencie.

    – Lucas Duarte
    Mar 28 at 5:56











  • Thats good news at least json error is gone. private SetService setServ; is null and any operation in the object will throw null pointer exception.

    – Satyendra Sharma
    Mar 28 at 5:57


















0
















for details check this link Jackson library.



@Entity
public class Partida implements Serializable
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String timeA;
private String timeB;
private boolean visitante;
public Partida()
//Default constructor required here

@OneToMany(mappedBy = "partida", fetch = FetchType.LAZY, cascade =
CascadeType.ALL)
private List<Set> sets;


public List<Set> getSets()
return sets;


public void setSets(List<Set> sets)
this.sets = sets;


public Long getId()
return id;


public void setId(Long id)
this.id = id;


public String getTimeA()
return timeA;


// Mocado o valor pois o Time A sempre e a Sao Judas
public void setTimeA(String timeA)
this.timeA = timeA;


public String getTimeB()
return timeB;


public void setTimeB(String timeB)
this.timeB = timeB;


public boolean isVisitante()
return visitante;


public void setVisitante(boolean visitante)
this.visitante = visitante;





if issue not not resolved then try JSON creator



@JsonCreator
public Partida(@JsonProperty("id") Long id, @JsonProperty("timeA") String
timeA, @JsonProperty("timeB") String timeB, @JsonProperty("desc") boolean
visitante)
this.id = id;
this.timeA = timeA;
this.timeB= timeB;
this.visitante= visitante;






share|improve this answer

























  • It does not work eaither, i tried with the empty constructor and with the annotatio @JsonCreator, the serveris always the same error

    – Lucas Duarte
    Mar 28 at 5:15












  • @LucasDuarte: create an empty constructor in your set class public Set() and after that share your error message

    – Ved Prakash
    Mar 28 at 5:26













Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55390335%2fhow-to-post-correctly-to-a-bidirectional-relationship%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0
















This issue has nothing to do with JPA bi-directional mapping. Its raising error at the time of de serializing.

Partida -> should have zero argument constructor



Request payload should have "partida":"id":123 in order to populate partida object property.






share|improve this answer

























  • When i tried this, i got the follow 2019-03-28 02:48:17.679 ERROR 8180 --- [nio-5888-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

    – Lucas Duarte
    Mar 28 at 5:49











  • You were right, just the way who i pass the JSON, and the null pointer exeception was because i forgot the @Autowired annotation tho inject the dependencie.

    – Lucas Duarte
    Mar 28 at 5:56











  • Thats good news at least json error is gone. private SetService setServ; is null and any operation in the object will throw null pointer exception.

    – Satyendra Sharma
    Mar 28 at 5:57















0
















This issue has nothing to do with JPA bi-directional mapping. Its raising error at the time of de serializing.

Partida -> should have zero argument constructor



Request payload should have "partida":"id":123 in order to populate partida object property.






share|improve this answer

























  • When i tried this, i got the follow 2019-03-28 02:48:17.679 ERROR 8180 --- [nio-5888-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

    – Lucas Duarte
    Mar 28 at 5:49











  • You were right, just the way who i pass the JSON, and the null pointer exeception was because i forgot the @Autowired annotation tho inject the dependencie.

    – Lucas Duarte
    Mar 28 at 5:56











  • Thats good news at least json error is gone. private SetService setServ; is null and any operation in the object will throw null pointer exception.

    – Satyendra Sharma
    Mar 28 at 5:57













0














0










0









This issue has nothing to do with JPA bi-directional mapping. Its raising error at the time of de serializing.

Partida -> should have zero argument constructor



Request payload should have "partida":"id":123 in order to populate partida object property.






share|improve this answer













This issue has nothing to do with JPA bi-directional mapping. Its raising error at the time of de serializing.

Partida -> should have zero argument constructor



Request payload should have "partida":"id":123 in order to populate partida object property.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 28 at 5:44









Satyendra SharmaSatyendra Sharma

762 bronze badges




762 bronze badges















  • When i tried this, i got the follow 2019-03-28 02:48:17.679 ERROR 8180 --- [nio-5888-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

    – Lucas Duarte
    Mar 28 at 5:49











  • You were right, just the way who i pass the JSON, and the null pointer exeception was because i forgot the @Autowired annotation tho inject the dependencie.

    – Lucas Duarte
    Mar 28 at 5:56











  • Thats good news at least json error is gone. private SetService setServ; is null and any operation in the object will throw null pointer exception.

    – Satyendra Sharma
    Mar 28 at 5:57

















  • When i tried this, i got the follow 2019-03-28 02:48:17.679 ERROR 8180 --- [nio-5888-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

    – Lucas Duarte
    Mar 28 at 5:49











  • You were right, just the way who i pass the JSON, and the null pointer exeception was because i forgot the @Autowired annotation tho inject the dependencie.

    – Lucas Duarte
    Mar 28 at 5:56











  • Thats good news at least json error is gone. private SetService setServ; is null and any operation in the object will throw null pointer exception.

    – Satyendra Sharma
    Mar 28 at 5:57
















When i tried this, i got the follow 2019-03-28 02:48:17.679 ERROR 8180 --- [nio-5888-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

– Lucas Duarte
Mar 28 at 5:49





When i tried this, i got the follow 2019-03-28 02:48:17.679 ERROR 8180 --- [nio-5888-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

– Lucas Duarte
Mar 28 at 5:49













You were right, just the way who i pass the JSON, and the null pointer exeception was because i forgot the @Autowired annotation tho inject the dependencie.

– Lucas Duarte
Mar 28 at 5:56





You were right, just the way who i pass the JSON, and the null pointer exeception was because i forgot the @Autowired annotation tho inject the dependencie.

– Lucas Duarte
Mar 28 at 5:56













Thats good news at least json error is gone. private SetService setServ; is null and any operation in the object will throw null pointer exception.

– Satyendra Sharma
Mar 28 at 5:57





Thats good news at least json error is gone. private SetService setServ; is null and any operation in the object will throw null pointer exception.

– Satyendra Sharma
Mar 28 at 5:57













0
















for details check this link Jackson library.



@Entity
public class Partida implements Serializable
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String timeA;
private String timeB;
private boolean visitante;
public Partida()
//Default constructor required here

@OneToMany(mappedBy = "partida", fetch = FetchType.LAZY, cascade =
CascadeType.ALL)
private List<Set> sets;


public List<Set> getSets()
return sets;


public void setSets(List<Set> sets)
this.sets = sets;


public Long getId()
return id;


public void setId(Long id)
this.id = id;


public String getTimeA()
return timeA;


// Mocado o valor pois o Time A sempre e a Sao Judas
public void setTimeA(String timeA)
this.timeA = timeA;


public String getTimeB()
return timeB;


public void setTimeB(String timeB)
this.timeB = timeB;


public boolean isVisitante()
return visitante;


public void setVisitante(boolean visitante)
this.visitante = visitante;





if issue not not resolved then try JSON creator



@JsonCreator
public Partida(@JsonProperty("id") Long id, @JsonProperty("timeA") String
timeA, @JsonProperty("timeB") String timeB, @JsonProperty("desc") boolean
visitante)
this.id = id;
this.timeA = timeA;
this.timeB= timeB;
this.visitante= visitante;






share|improve this answer

























  • It does not work eaither, i tried with the empty constructor and with the annotatio @JsonCreator, the serveris always the same error

    – Lucas Duarte
    Mar 28 at 5:15












  • @LucasDuarte: create an empty constructor in your set class public Set() and after that share your error message

    – Ved Prakash
    Mar 28 at 5:26















0
















for details check this link Jackson library.



@Entity
public class Partida implements Serializable
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String timeA;
private String timeB;
private boolean visitante;
public Partida()
//Default constructor required here

@OneToMany(mappedBy = "partida", fetch = FetchType.LAZY, cascade =
CascadeType.ALL)
private List<Set> sets;


public List<Set> getSets()
return sets;


public void setSets(List<Set> sets)
this.sets = sets;


public Long getId()
return id;


public void setId(Long id)
this.id = id;


public String getTimeA()
return timeA;


// Mocado o valor pois o Time A sempre e a Sao Judas
public void setTimeA(String timeA)
this.timeA = timeA;


public String getTimeB()
return timeB;


public void setTimeB(String timeB)
this.timeB = timeB;


public boolean isVisitante()
return visitante;


public void setVisitante(boolean visitante)
this.visitante = visitante;





if issue not not resolved then try JSON creator



@JsonCreator
public Partida(@JsonProperty("id") Long id, @JsonProperty("timeA") String
timeA, @JsonProperty("timeB") String timeB, @JsonProperty("desc") boolean
visitante)
this.id = id;
this.timeA = timeA;
this.timeB= timeB;
this.visitante= visitante;






share|improve this answer

























  • It does not work eaither, i tried with the empty constructor and with the annotatio @JsonCreator, the serveris always the same error

    – Lucas Duarte
    Mar 28 at 5:15












  • @LucasDuarte: create an empty constructor in your set class public Set() and after that share your error message

    – Ved Prakash
    Mar 28 at 5:26













0














0










0









for details check this link Jackson library.



@Entity
public class Partida implements Serializable
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String timeA;
private String timeB;
private boolean visitante;
public Partida()
//Default constructor required here

@OneToMany(mappedBy = "partida", fetch = FetchType.LAZY, cascade =
CascadeType.ALL)
private List<Set> sets;


public List<Set> getSets()
return sets;


public void setSets(List<Set> sets)
this.sets = sets;


public Long getId()
return id;


public void setId(Long id)
this.id = id;


public String getTimeA()
return timeA;


// Mocado o valor pois o Time A sempre e a Sao Judas
public void setTimeA(String timeA)
this.timeA = timeA;


public String getTimeB()
return timeB;


public void setTimeB(String timeB)
this.timeB = timeB;


public boolean isVisitante()
return visitante;


public void setVisitante(boolean visitante)
this.visitante = visitante;





if issue not not resolved then try JSON creator



@JsonCreator
public Partida(@JsonProperty("id") Long id, @JsonProperty("timeA") String
timeA, @JsonProperty("timeB") String timeB, @JsonProperty("desc") boolean
visitante)
this.id = id;
this.timeA = timeA;
this.timeB= timeB;
this.visitante= visitante;






share|improve this answer













for details check this link Jackson library.



@Entity
public class Partida implements Serializable
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String timeA;
private String timeB;
private boolean visitante;
public Partida()
//Default constructor required here

@OneToMany(mappedBy = "partida", fetch = FetchType.LAZY, cascade =
CascadeType.ALL)
private List<Set> sets;


public List<Set> getSets()
return sets;


public void setSets(List<Set> sets)
this.sets = sets;


public Long getId()
return id;


public void setId(Long id)
this.id = id;


public String getTimeA()
return timeA;


// Mocado o valor pois o Time A sempre e a Sao Judas
public void setTimeA(String timeA)
this.timeA = timeA;


public String getTimeB()
return timeB;


public void setTimeB(String timeB)
this.timeB = timeB;


public boolean isVisitante()
return visitante;


public void setVisitante(boolean visitante)
this.visitante = visitante;





if issue not not resolved then try JSON creator



@JsonCreator
public Partida(@JsonProperty("id") Long id, @JsonProperty("timeA") String
timeA, @JsonProperty("timeB") String timeB, @JsonProperty("desc") boolean
visitante)
this.id = id;
this.timeA = timeA;
this.timeB= timeB;
this.visitante= visitante;







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 28 at 5:09









Ved PrakashVed Prakash

1,0714 gold badges19 silver badges30 bronze badges




1,0714 gold badges19 silver badges30 bronze badges















  • It does not work eaither, i tried with the empty constructor and with the annotatio @JsonCreator, the serveris always the same error

    – Lucas Duarte
    Mar 28 at 5:15












  • @LucasDuarte: create an empty constructor in your set class public Set() and after that share your error message

    – Ved Prakash
    Mar 28 at 5:26

















  • It does not work eaither, i tried with the empty constructor and with the annotatio @JsonCreator, the serveris always the same error

    – Lucas Duarte
    Mar 28 at 5:15












  • @LucasDuarte: create an empty constructor in your set class public Set() and after that share your error message

    – Ved Prakash
    Mar 28 at 5:26
















It does not work eaither, i tried with the empty constructor and with the annotatio @JsonCreator, the serveris always the same error

– Lucas Duarte
Mar 28 at 5:15






It does not work eaither, i tried with the empty constructor and with the annotatio @JsonCreator, the serveris always the same error

– Lucas Duarte
Mar 28 at 5:15














@LucasDuarte: create an empty constructor in your set class public Set() and after that share your error message

– Ved Prakash
Mar 28 at 5:26





@LucasDuarte: create an empty constructor in your set class public Set() and after that share your error message

– Ved Prakash
Mar 28 at 5:26

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55390335%2fhow-to-post-correctly-to-a-bidirectional-relationship%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴