Reputation: 3547
I get the exception org.hibernate.HibernateException: Errors in named queries: ElaborazionePagamentiMaggioriOneri.estrai
but the named query looks correct to me. I also get
org.hibernate.hql.ast.QuerySyntaxException: ElaborazionePagamentiMaggioriOneri is not mapped [FROM ElaborazionePagamentiMaggioriOneri e WHERE e.dataInizioLancio IS NULL AND e.dataFineLancio IS NULL AND e.distinta IS NULL]
My entity is the following:
@Entity(name="ELABORAZIONE_PAGAMENTI")
@Table(name="ELABORAZIONE_PAGAMENTI")
@NamedQuery(name="ElaborazionePagamentiMaggioriOneri.estrai",
query="FROM ElaborazionePagamentiMaggioriOneri e WHERE e.dataInizioLancio IS NULL AND e.dataFineLancio IS NULL AND e.distinta IS NULL")
public class ElaborazionePagamentiMaggioriOneri {
@Id
@GeneratedValue
@Column(name="ID_ELABORAZIONE")
private long idElaborazione;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="ID_INTERVALLO")
private Intervallo intervallo;
@Column(name="IMPORTO_MINIMO")
private BigDecimal importoMinimo;
@Column(name="IMPORTO_MASSIMO")
private BigDecimal importoMassimo;
@Column(name="LIMITE_DISPOSIZIONI")
private Long limiteDisposizioni;
@Column(name="DATA_INIZIO_LANCIO")
private Calendar dataInizioLancio;
@Column(name="DATA_FINE_LANCIO")
private Calendar dataFineLancio;
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="ID_DISTINTA")
private DistintaMaggioriOneri distinta;
What is the origin of the error? I have double checked the JPQL syntax.
Upvotes: 2
Views: 25687
Reputation: 2732
Entity name
used with @Entity
and the name of the entity you are using inside Select query should be same, if you are not using entity name with @Entity
then class name should be used with the Select query. Check this properly.
Upvotes: 13
Reputation: 3547
The problem is that if you put the annotation @Entity(name="ELABORAZIONE_PAGAMENTI")
you set the name of the entity to be ELABORAZIONE_PAGAMENTI.
There are two solutions:
FROM ELABORAZIONE_PAGAMENTI e WHERE e.dataInizioLancio IS NULL AND e.dataFineLancio IS NULL AND e.distinta IS NULL
@Entity
annotation by removing the name
propertyUpvotes: 3
Reputation: 216
In addition to missing SELECT, the "is not mapped" error is probably because you don't have the class registered in persistence.xml.
Upvotes: 1
Reputation: 415
You are missing SELECT
in your query.
query="SELECT e FROM ElaborazionePagamentiMaggioriOneri e WHERE
Upvotes: 2