I'm trying to retrieve idPatient from the database but i keep getting errors, idPatient is auto increment. But i don't know if that's what causing the problem.
This is the code i'm trying
public List<Patient> getPatientsFromDatabase() {
String sql = "SELECT naam, voornaam, gebit, idPatient from patienten";
try (Connection con = sql2o.open()) {
return con.createQuery(sql)
.throwOnMappingFailure(false)
.executeAndFetch(Patient.class);
}
}
the DB:
The error:
Edit - Patient:
public Patient(String voornaam, String naam, String gebit, int id) {
this.voornaam = voornaam;
this.naam = naam;
this.id = id;
if (null != gebit)switch (gebit) {
case "melkgebit":
g = new Melkgebit();
this.gebit = "melkgebit";
break;
case "volwassengebit":
g = new Volwassengebit();
this.gebit = "volwassengebit";
break;
case "wisselgebit":
this.gebit = "wisselgebit";
break;
default:
break;
}
}