2
When performing a query in the database with JPA
+ HIBERNATE
the following exception shall be made:
java.lang.IllegalArgumentException: Unknown name value [Respondido] for enum class [java.lang.Enum]
I cannot understand the reason for the error, in theory it should be making the Binding correctly for the database column.
This is my Enum
in @Entity
@Enumerated(EnumType.STRING)
@Column(name = "situacao", nullable = true)
private Enum<SituacaoAvaliacaoPedidoEnum> situacao;
And this is my query query, I’m using the interface SimpleJPARepository
.
@Query("SELECT situacao FROM AvaliacaoPedido ap WHERE ap.idPedido = :idPedido")
public String consultarSituacaoPedido(@Param("idPedido") Integer idPedido);
And this is my Enum
:
public enum SituacaoAvaliacaoPedidoEnum {
EsperandoResposta,
Respondido,
FalhaEnvio,
Ignorado,
ExcedeuTentativa;
}
I already saw in a question of the GUJ that the problem could be that in the bank the Enum
could be in full, but this is not my case, the Num in my bank are all String
as you can see below:
Hello @Anthonyaccioly I performed the
SELECT DISTINCT
in the comic book and there was no value stuck, so I did what you said I changed theprivate Enum<SituacaoAvaliacaoPedidoEnum> situacao;
forprivate SituacaoAvaliacaoPedidoEnum situacao;
and it worked, could you just do me two more favors? 1° - could you put that comment of yours as an answer so I can mark the question with the answer? the 2° is if you would not have some article you recommend and talk about those type Erasure I would like to know more about the subject.– Brendon Iwata