I use spring boot with spring data jpa
I have a field with a integer data type. I have an enum with different value for this field
public class Operation{
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "operation_Sequence")
@SequenceGenerator(name = "operation_Sequence", sequenceName = "operation_Sequence", allocationSize = 1)
private Long id;
private Integer eventProcessStatus;
}
public enum EventProcessStatus {
CLOSE(2),
OPEN(99);
private final int id;
EventProcessStatus(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
In my repository, I search to use this enum with the getId method
@Query(value = "select ce from Operation ce where "
+ "(ce.eventProcessStatus=com.ns.perma.domain.constants.EventProcessStatus.CLOSE.getId() )")
public List<Operation> findAllOperation();
When this query is executed, I get CLOSE: INVALID IDENTIFIER.
In the sql log I see
...
where
operation0_.event_process_status=com.ns.perma.billing.domain.constants.EventProcessStatus.SUCCESS.getId()
So the command is not converted.
Any idea?