Hello,
after upgrading from hibernate 5 to hibernate 6.6.0.FINAL, the following query stopped working:
entityManager.createQuery("select t from EntityWithStatus t where t.status < org.hibernate.bugs.Status.ONE").getResultList()
and starts throwing an assertion error in org.hibernate.sql.ast.tree.expression.QueryLiteral#QueryLiteral.
Is this type of query no longer supported or a bug?
Thanks in advance!
For reference:
@Entity
public class EntityWithStatus {
@Id
@GeneratedValue
private Long id;
@Convert(converter = StatusConverter.class)
private Status status;
public Long getId() {
return id;
}
public Status getStatus() {
return status;
}
}
public class Status implements Serializable {
private static final Map<Integer, Status> VALUES = new HashMap<>();
public static Status ONE = new Status(1);
public static Status TWO = new Status(2);
private final int value;
Status(int value) {
this.value = value;
VALUES.put(value, this);
}
public int getValue() {
return value;
}
public static Status from(int value) {
return VALUES.get(value);
}
@Override
public String toString() {
return "Status{" + "value=" + value + '}';
}
}
@Converter
public class StatusConverter implements AttributeConverter<Status, Integer> {
@Override
public Integer convertToDatabaseColumn(Status attribute) {
return attribute == null ? null : attribute.getValue();
}
@Override
public Status convertToEntityAttribute(Integer dbData) {
return dbData == null ? null : Status.from(dbData);
}
}