I’m in the process of upgrading an application from Spring Boot 2.7 and Hibernate 5 to Spring Boot 3.1.2 and Hibernate 6.2.6 and am running into an issue with a query that did not previously present any issue. Note that I’m running an SQL Server 2017 database to which data is to be persisted.
In my repository class, I have the following query.
@Modifying
@Transactional
@Query("UPDATE Employee AS e SET e.medicalActive = ?2, e.dentalActive = ?2 WHERE e.employeeId.nationalId IN ?1)
void updateEmployeeHealthStatus(List<String> nationalIds, boolean healthInsuranceActive);
The entity class is pretty standard. I have the two boolean fields that I’m trying to update declared as below.
@Column(name = "[MEDICAL_ACTIVE]")
@JsonProperty("MEDICAL_ACTIVE")
@Convert(converter = YesNoConverter.class)
private boolean medicalActive;
@Column(name = "[DENTAL_ACTIVE]")
@JsonProperty("DENTAL_ACTIVE")
@Convert(converter = YesNoConverter.class)
private boolean dentalActive;
When I execute the query, I’m observing the following error.
org.hibernate.sql.exec.ExecutionException: A problem occurred in the SQL executor : JDBC parameter value not bound - org.hibernate.sql.exec.internal.SqlTypedMappingJdbcParameter@6e03373d
If I remove the converter annotation from both fields, the query runs fine. Unfortunately, instead of storing Y or N in the database fields - both of which are set to VARCHAR(1) type - it stores 1 or 0. I’d prefer to store the Y or N values instead.
What am I doing wrong?