I'm facing this error
No converter found capable of converting from type [java.lang.Integer] to type [@org.springframework.data.jpa.repository.Query com.kevcode.saludxi.citasmcs.models.entity.Appointment]
When I try to use @Query in my method.
Method:
@Query("SELECT a.id, a.appointmentDate, a.appointmentTypeId, at.name as appointmentTypeName, " +
"a.feeValue, at.lengthInMinutes, a.medicId, a.patientId, a.symptomId" +
" FROM Appointment a INNER JOIN AppointmentType at ON at.id = a.appointmentTypeId" +
" WHERE a.appointmentDate >= ?1 AND a.appointmentDate <= ?2 AND a.medicId = ?3")
List<Appointment> findAllBetweenDateAndMedicId(Date maxDate, Date minDate, int medicId);
Appointment Class
public class Appointment extends EntityBase {
//private int id **extended from EntityBase**
private int appointmentTypeId;
private int symptomId;
private int medicId;
private int patientId;
@Column(name="appointmet_date")
private LocalDateTime appointmentDate;
private float feeValue;
@Transient
private int lengthInMinutes;
@Transient
private String appointmentTypeName;
}
Stacktrace:
org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.Object[]] to type [@org.springframework.data.jpa.repository.Query com.kevcode.saludxi.citasmcs.models.entity.Appointment] for value '{78532, 2022-05-24 00:46:14.0, 2, Examen, 3000.0, 30, 61, 21, 41}'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.Integer] to type [@org.springframework.data.jpa.repository.Query com.kevcode.saludxi.citasmcs.models.entity.Appointment]