mardi 7 juin 2022

Java Spring Argument Type Mismatch at org.sql2o.reflection.MethodSetter.setProperty(MethodSetter.java:27)

I've got this error that sometimes shows up. When I reload the project disappears, only to show up again at random, and I don't know why it happens.

I invoke this method in the EmployeeRepositoryImpl class:

@Override
public Employee getById(Long idemployee) {
    logger.info("GET EMPLOYEE BY ID");
    try (Connection con = sql2o.open()) {
        return con.createQuery("SELECT e.EMPLOYEEID, e.NAME, e.SURNAME, CONCAT( e.SURNAME, CONCAT(' ',e.NAME)) AS NOMINATIVO, e.TAXCODE, e.CONTRACTTYPE, e.CONTRACTEXPIRY, e.EMPLOYEETYPE, e.FLGACTIVE," +
                        " e.SUPPLIERID, e.INSERTEDBY, e.INSERTEDON, e.MODIFIEDBY, e.MODIFIEDBY, e.MODIFIEDON, e.SUBCONTRACTORCOMPANY FROM EMPLOYEE e where e.EMPLOYEEID = :employeeid")
                 .addParameter("employeeid", employeeId)
                 .executeAndFetchFirst(Employee.class);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw e;
    }
}

by using this

Employee employee = employeeService.getById(employeeId);

The Employee class is:

public class Employee {

private Long employeeid;
private String name;
private String surname;
//other properities

public Long getEmployeeid() {
    return employeeid;
}

public void setEmployeeid(Long employeeid) {
    this.employeeid = employeeid;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}
//other getters and setters

The error is this

java.lang.IllegalArgumentException: argument type mismatch
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.sql2o.reflection.MethodSetter.setProperty(MethodSetter.java:27)
at org.sql2o.DefaultResultSetHandlerFactory$6.handle(DefaultResultSetHandlerFactory.java:236)
at org.sql2o.PojoResultSetIterator.readNext(PojoResultSetIterator.java:33)
at org.sql2o.ResultSetIteratorBase.safeReadNext(ResultSetIteratorBase.java:88)
at org.sql2o.ResultSetIteratorBase.hasNext(ResultSetIteratorBase.java:52)
at org.sql2o.Query.executeAndFetchFirst(Query.java:618)
at org.sql2o.Query.executeAndFetchFirst(Query.java:607)
at it.niuma.epp.repository.EmployeeRepositoryImpl.getById(EmployeeRepositoryImpl.java:78)

Let me know if others information or bits of code are needed. Thanks!





Aucun commentaire:

Enregistrer un commentaire