Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPA Query Entity not mapped error

Tags:

java

jpa

hql

jpql

Testing is not passing in the following code. Debugging shows the error is in the creation of the query.

java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Catalog is not mapped [SELECT c FROM Catalog c WHERE c.name = :name]
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1347)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1288)

Entity class:

@Entity
@Table(name = "eb_catalog", uniqueConstraints=@UniqueConstraint(columnNames="name"))
public class Catalog implements ICatalog, Serializable {

and the query itself:

TypedQuery<Catalog> query = em.createQuery(
"SELECT c FROM Catalog c WHERE c.name = :name", Catalog.class)
.setParameter("name", catName);

CTRL + click on Catalog is opening the entity, so the name matches the entity in the query.

thanks in advance.

like image 823
mt.uulu Avatar asked Dec 26 '22 09:12

mt.uulu


1 Answers

You may have forgotten to map your entity class in the persistence.xml. Take a look :)

like image 152
Giovani Guizzo Avatar answered Jan 19 '23 03:01

Giovani Guizzo