Is there any way to pass as a parameter in a NamedQuery
the value of Enum
.
public enum TipoConta{
CREDITO("Cartao de Credito"), DEBITO("Cartao de Debito");
private final String descricao;
TipoConta(String descricao) {
this.descricao = descricao;
}
@Query("SELECT g FROM Gasto g WHERE g.transacao.tipo.nome = TipoConta.DEBITO.descricao")
List<Gasto> findAllGastos();
}
This is an example of what I'd like to do, in my code I need to pass as condition, and I'll give a description. But I would not like to leave as hard code in Query
, and pass a constant of a Enum
, so I only change the Enum
and change in all Query
.