Tables
@Data
@Entity
@Table(name = "A")
class A {
private Long id;
private Long bId;
}
@Data
@Entity
@Table(name = "B")
class B {
private Long id;
@Enumerated(EnumType.STRING)
private Status status;
}
enum Status {
NEW,
VALIDATED,
ARCHIVE
}
I have a following native query
@Query(value = "SELECT cast(a.id as varchar) FROM a
INNER JOIN b on a.id = b.id
WHERE a.id = :id AND
b.status = 'NEW'", // here I need smth like b.status = '" + Status.NEW + "' ",
nativeQuery = true)
Set<UUID> findIdByStatuses(@Param UUID id)
Instead of b.status = 'NEW', I need smth like b.status = '" + Status.NEW + "' ",
to get a compile error when name of Status changes. But it is not working like this. And the question is how to reach that desirable concatenation inside of native query without method argumetns