Hello everyone , I have been trying all day to persist an entity “resultatRAT”
ResultatRAT.class
@Entity
@Table(name = "resultat_rat")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorValue("REMBOURSEMENT_TOTAL")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class ResultatRAT extends Resultat implements Serializable {
private static final long serialVersionUID = 1L;
@NotNull
@Column(name = "montant_remboursement", nullable = false)
private Float montantRemboursement;
@NotNull
@Column(name = "pre_solde_dispo", nullable = false)
private Float preSoldeDispo;
@NotNull
@Column(name = "post_solde_dispo", nullable = false)
private Float postSoldeDispo;
@NotNull
@Column(name = "duree_restante", nullable = false)
private Integer dureeRestante;
@NotNull
@Column(name = "pre_echeance", nullable = false)
private Float preEcheance;
@NotNull
@Column(name = "post_echeance", nullable = false)
private Float postEcheance;
@NotNull
@Column(name = "capital_amorti", nullable = false)
private Float capitalAmorti;
@NotNull
@Column(name = "capital_restant_du", nullable = false)
private Float capitalRestantDu;
@NotNull
@Column(name = "mnt_penalite_ht", nullable = false)
private Float mntPenaliteHT;
@NotNull
@Column(name = "taxe_penalite_ht", nullable = false)
private Float taxePenaliteHT;
// Getters and setter omitted for brevity
}
this is the mother class “Resultat”
Resultat.class
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "resultat")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@DiscriminatorColumn(name = "typeSimulation", discriminatorType = DiscriminatorType.STRING)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME
, property = "typeSimulation")
@JsonSubTypes(
{
@JsonSubTypes.Type(value = ResultatRAP.class, name = "REMBOURSEMENT_PARTIEL"),
@JsonSubTypes.Type(value = ResultatRAT.class, name = "REMBOURSEMENT_TOTAL"),
}
)
public abstract class Resultat implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@OneToOne(mappedBy = "resultat", cascade = CascadeType.PERSIST, orphanRemoval = true)
private Simulation simulation;
@Column(name = "typeSimulation", nullable = false)
@Enumerated(EnumType.STRING)
private TypeSimulation typeSimulation;
// Getters and setter omitted for brevity
}
but each attempt have been a failure , the post method is pretty standard
@PostMapping("/resultats")
public Resultat createResultat(@RequestBody Resultat resultat) throws URISyntaxException {
if (resultat.getId() != null) {
throw new BadRequestAlertException("A new resultat cannot already have an ID", ENTITY_NAME, "idexists");
}
Resultat result = resultatRepository.save(resultat);
return result;
}
and this is my JSON object
{
"typeSimulation":"REMBOURSEMENT_TOTAL",
"montantRemboursement":22.0,
"preSoldeDispo":2222.0,
"postSoldeDispo":2.0,
"dureeRestante":221,
"preEcheance":341.0,
"postEcheance":53.0,
"capitalAmorti":12345.0,
"capitalRestantDu":235.0,
"mntPenaliteHT":231.0,
"taxePenaliteHT":231.0
}
each time I request my object to be persisted I get this error
Invalid value “1” for parameter “parameterIndex” [90008-200]
Any idea on how to solve this problem? Thank you very much