Error on compiling query: The abstract schema type 'entity' is unknown

不羁的心 提交于 2019-11-30 08:39:25
Andrei I

You should have

SELECT g FROM Game g//you have game

but you have game instead of Game.

The @Table annotation is used for DB.

If you need to change the name in your JPQL, use the @Entity annotation: @Entity(name="nameUsedInJPQL") => nameUsedInJPQL is used in your JPQL.

If you do not specify anything in your @Entity, that the case-sensitive Entity class name is used.

leomeurer

In my case I forgot to register it in persistence.xml.

I just had the very same situation but my JPQL query was correct ! It occured in Glassfish 4.1 (build 13) (with EclipseLink).

After a few googling and some code commenting, I found out that the root cause of "The abstract schema type 'MyEntity' is unknown" was some use of Java 8 lambda code inside the entity class.

It seems that any feature of Java 8 is not (yet) supported in the version of EclipseLink that comes with GF. More info, see the bug report on that.

Hope this helps.

The name to be used for JPQL queries is defined as the simple name of the entity class - Game or Human in your case. It can be overridden by the name attribute of the @Entity annotation. @Table is a physical mapping annotation and does not influence the entity name in the query.

It does work with human because the query string is not case-sensitive.

class name should be there not the table name in your query SELECT g FROM Game g

We got the problem due to an update of org.eclipse.persistence.eclipselink library from 2.4.0 to 2.5.1. After updating to 2.6.2 it works again.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!