During the process of migration from SpringBoot 2.x.x to 3.x.x (and effectively Hibernate) I got stuck on a problem with entity column value converters.
I got the entity with Boolean type field, which is stored in the DB as either Y, N or null (varchar2 (1 char)):
@Entity
@Table(name = "ENTITY_WITH_CONVERTED_FIELD")
public class EntityWithConvertedField {
@Id
@Column(name = “ID”)
private Long id;
@Column(name = “MY_FLAG)
@Convert(converter = YesNoConverter.class) // OOTB converter from org.hibernate.type package
private Boolean myFlag; // this value is stored as either ‘Y’, ‘N’ or null in the db
}
When this entity is then used in the queries (ex. CriteriaQuery, queries in the annotations of repository methods) I keep getting exceptions that looks like more or less like this:
org.springframework.dao.InvalidDataAccessResourceUsageException: JDBC exception executing SQL [select mt1_0.ID from EntityWithConvertedField mt1_0 where mt1_0.MY_FLAG = false and mt1_0.ID=?] [ORA-00904: "FALSE": invalid identifier] [n/a]; SQL [n/a]
It would suggest that no conversion happens on the Hibernate side.
On Hibernate versions prior to the 6.x, everything worked like a charm.
I’m running on SpringBoot 3.1.4 (with Hibernate 6.2.9.Final). I’ve tried bumping the Hibernate version to the latest one but with no luck.
Thanks in advance!