使用 eclipselink 连接表
如何从 Eclipse Link 中的两个或多个表获取数据?我尝试使用传统 SQL 但代码抛出以下错误?
编译查询时出错 [SELECT I.item_id 、 I.item_desc 、 A.auction_start_ts 、 A.auction_end_ts 来自项目 I 、 拍卖 A ,AUCTION_ITEMS AI WHERE A.auction_id = AI.auction_id AND I.item_id = AI.auction_id]。未知实体 输入[项目]。
我已使用 @Entity 注释了 Item、Auction 和 Auction_Items 域类。
这是我的查询。
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 ;
有人可以帮我吗?
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_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 ;
Could someone help me here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从异常看来,您正在使用 JPQL 而不是本机 SQL 查询。如果您使用 Java SE 部署,请确保 persistence.xml 文件中列出的所有实体。您是否在 @Entity 注释中指定了“name”属性?如果有的话,它与“Item”完全匹配吗?实体类的名称是否与“Item”完全匹配。
如果这些建议都没有帮助,那么我建议发布有关您的部署的更多信息,包括部署类型和目标环境(Java EE、Java SE、Tomcat、Spring 等),并发布 persistence.xml 文件和您的部署的定义部分。实体类。
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.