使用 eclipselink 连接表

发布于 2024-10-09 06:12:56 字数 651 浏览 0 评论 0原文

如何从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2024-10-16 06:12:56

从异常看来,您正在使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文