我有以下查询休眠下但不是下蚀作品:

select o from Organisation o where o.code=:code and o.type=:type

这是我不明白,为什么是这样的话,我希望别人能详细给我们。返回的错误是:

Caused by: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: 
Exception Description: Error compiling the query [select o from Organisation o where  o.code=:code and o.type=:type]. Unknown entity type [Organisation].

我们已经从在persistence.xml文件切换提供者类来表示我们现在用的EclipseLink再没其他变化分开。

有帮助吗?

解决方案

像的EclipseLink外貌不扫描您的JAR文件/包含组织类的类的部分。明确声明它在persistence.xml中,看看会发生什么:

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
             version="2.0">
<persistence-unit name="YourPersUnit">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

    <class>foo.bar.Organisation</class>
</persistence-unit>
</persistence>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top