HibernateとEclipseLinkの間JPQLのinconsitency
-
27-09-2019 - |
質問
I休止状態の下で働き、次のクエリを持ってではなく、日食の下でます:
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].
私たちは今のEclipseLinkを使用している示すために、persistence.xmlファイルにプロバイダクラスの切り替えから離れて他の変更を行っていない。
解決
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>
所属していません StackOverflow