Join tables using eclipselink
How would I fetch data from two or more tables in Eclipse Link? I am trying to use conventional SQL but the code throws the following error?
Error compiling the query [SELECT I.item_id , I.item_desc , A.auction_start_ts , A.auction_end_ts FROM Item I , Auction A , AUCTION_ITEMS AI WHERE A.auction_id = AI.auction_id AND I.item_id = AI.auction_id ]. Unknown entity type [Item].
I have annotated the Item, Auction and Auction_Items domain classes with @Entity.
This is my query.
SELECT I.item_i开发者_开发技巧d
, I.item_desc
, A.auction_start_ts
, A.auction_end_ts
FROM
ITEM I
, AUCTION A
, AUCTION_ITEMS AI
WHERE
A.auction_id = AI.auction_id
AND I.item_id = AI.auction_id ;
Could someone help me here?
From the Exception is appears you are using JPQL and not a native SQL query. If you are using Java SE deployment then ensure all of the Entities as listed in the persistence.xml file. Have you specified the "name" attribute in the @Entity annotation? If you have does it match exactly with "Item"? Does the name of the Entity class exactly match "Item".
If none of these suggestions help then I recommend posting more information on your deployment include type of deployment and target environment (Java EE, Java SE, Tomcat, Spring, etc..) and post the persistence.xml file and the definition parts of your Entity classes.
精彩评论