Hello.
I’m dealing with a nasty bug! I mapped a class (JPA - Application First) in the beans folder and there was a typo: id
was written as ind
. I fixed the typo. In MySQL the column is as id
, however, Postman only accepts ind
and when I used my browser’s localhost,
it appears as ind.
Because of this issue, I cannot make a GET
call from Postman without deleting the inner join
between two columns, and whenever I do a POST
to create a new entry on MySQL, the id
—or, in my case, ind—
is generating id numbers out of wack.
I’ve been trying to fix this for a while. Thanks!
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
@Entity
@Table(name="tb_candidato2")
public class Candidato2 {
@Id
@Column(name="id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name="nome")
private String nome;
@Column(name="sobrenome")
private String sobreNome;
@Column(name="idade")
private short idade;
@Column(name="cpf")
private String cpf;
@Column(name="genero")
private String genero;
@Column(name="email")
private String email;
@Column(name="celular")
private int celular;
//@OneToOne
//@JsonIgnoreProperties("candidato2")
//private Endereco2SU endereco2SU;
//@JsonBackReference
/*
public Endereco2SU getEndereco() {
return endereco2SU;
}
public void setEndereco(Endereco2SU endereco) {
this.endereco2SU = endereco;
}*/
public int getInd() {
return id;
}
public void setInd(int id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getSobreNome() {
return sobreNome;
}
public void setSobreNome(String sobreNome) {
this.sobreNome = sobreNome;
}
public short getIdade() {
return idade;
}
public void setIdade(short idade) {
this.idade = idade;
}
public String getCpf() {
return cpf;
}
public void setCpf(String cpf) {
this.cpf = cpf;
}
public String getGenero() {
return genero;
}
public void setGenero(String genero) {
this.genero = genero;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public int getCelular() {
return celular;
}
public void setCelular(int celular) {
this.celular = celular;
}
}
Localhost
from browser:
0
nome "Aldair"
sobreNome "Venancio"
idade 23
cpf "1342354323"
genero "Masculino"
email "aldvenan01@hotmail.com"
celular 980143556
ind 1
MySQL:
I updated Ids 1, 2 and 3 via MySQL. 102, 152 and 202 (increments of 50) are being done via @GeneratedValue
when doing POST
via Postman.