JPQL عدم اتساق بين السبات و Eclipselink
-
27-09-2019 - |
سؤال
لدي الاستعلام التالي الذي يعمل تحت سبات ولكن ليس تحت الكسوف:
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].
لم نقم بأي تغييرات أخرى بصرف النظر عن تبديل فئة المزود في ملف pressustence.xml للإشارة إلى أننا نستخدم الآن Eclipselink.
المحلول
يبدو أن Eclipselink لا يقوم بمسح جزء من ملفات/فئات JAR التي تحتوي على فئة المؤسسة. أعلن أنه بشكل صريح في الثبات. 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