I have an Entity like this:
package it.infogroup.vertenze.entities;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
@Entity
@Table(name = "RICHIESTE_ESPORTAZIONE_ISIDORO")
@NamedQueries({
@NamedQuery(name = "findFlussoDatiGeneraliByStato",
query = "select r from RichiestaEsportazioneIsidoro r
where r.stato = it.infogroup.vertenze.entities.
RichiestaEsportazioneIsidoro$StatoRichiesta.NEW
or r.stato = it.infogroup.vertenze.entities.
RichiestaEsportazioneIsidoro$StatoRichiesta.FAIL
and r.tipoFlusso = it.infogroup.vertenze.entities.
RichiestaEsportazioneIsidoro$TipoFlusso.DATI_GENERALI"),
@NamedQuery(name = "findFlussoAccantonamentiByStato",
query = "select r from RichiestaEsportazioneIsidoro r
where r.stato = it.infogroup.vertenze.entities.
RichiestaEsportazioneIsidoro$StatoRichiesta.NEW
or r.stato = it.infogroup.vertenze.entities.
RichiestaEsportazioneIsidoro$StatoRichiesta.FAIL
and r.tipoFlusso = it.infogroup.vertenze.entities.
RichiestaEsportazioneIsidoro$TipoFlusso.ACCANTONAMENTI")
})
public class RichiestaEsportazioneIsidoro implements Serializable {
public final static String QUERY_FIND_BY_LOTTO_AND_STATO =
"findRichiestaByLottoAndStato";
public enum StatoRichiesta {
NEW,
ELAB,
SENT,
FAIL
}
public enum TipoFlusso {
DATI_GENERALI,
ACCANTONAMENTI
}
On deploying I'm getting this error:
01/12/2014 16:59 [ERROR]: org.hibernate.impl.SessionFactoryImpl -
Error in named query: findFlussoAccantonamentiByStato
org.hibernate.hql.ast.QuerySyntaxException:
unexpected token: . near line 1, column 167 [select r from
it.infogroup.vertenze.entities.RichiestaEsportazioneIsidoro r
where r.stato = it.infogroup.vertenze.entities.
RichiestaEsportazioneIsidoro$StatoRichiesta.NEW
or r.stato = it.infogroup.vertenze.entities.
RichiestaEsportazioneIsidoro$StatoRichiesta.FAIL
and r.tipoFlusso = it.infogroup.vertenze.entities.
RichiestaEsportazioneIsidoro$TipoFlusso.ACCANTONAMENTI]
Can someone help me understand what I'm doing wrong? Thank you.
I think is related to this hibernate bug https://hibernate.atlassian.net/browse/HHH-8368
You're using a JPQL reserved word
NEW
for your enum value. Try using another name for new, hibernate fail to handle such case.Below you can check the list of JPQL reserved words. https://docs.oracle.com/html/E24396_01/ejb3_langref.html#ejb3_langref_from_identifiers