I have migrated from Hibernate 6.1.7.Final to 6.2.6.Final (bug exists also in 6.2.0.Final) and there are some enum related issues. I have a query as below, that was working in older version, but it is failing now:
select datasourceView.id, max(datasourceView.datasourceStatus) as DATASOURCE_STATUS_helper_column, datasourceView.id as ID_helper_column
The error is:
org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.QueryException: Parameter 1 of function max() has type COMPARABLE, but argument is of type com.xxx.datasource.domain.DatasourceStatus
Enum mapping:
@Column(name = "status")
@Enumerated(EnumType.STRING)
private DatasourceStatus datasourceStatus;
I have solved the issue by switching from the @Enumerated to the @Converter and creating a converter for enums.