IntelliJ idea JPA实体类 提示 Cannot resolve column “id”

本文介绍了解决IDEA中使用Spring配置的Hibernate项目出现的实体类注解错误提示的方法。通过将数据源与持久化单元或SessionFactory关联,可以消除IDEA发出的关于字段未与数据源关联的警告。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

You have to associate your data source (create a data source in database view first - aka your real JDBC database connection) with a persistence unit or session factory (hibernate.cfg.xml).

Follow below steps and the warnings will disappear:

  1. Open the Persistence tool window (View | Tool Windows | Persistence).
  2. Right-click the necessary module, persistence unit or session factory, and select Assign Data Sources in the context menu.

  1. In the Assign Data Sources dialog that opens, click the Data Source field and select the necessary data source. (To remove the association with the data source, select .)

我用spring配置文件applicationContext.xml托管hibernate,生成的实体类中的注解有错误,提示:Cannot resolve column “id”;这个错误是idea检测出来的,实际并不影响运行,错误的原因是因为注解的字段没有与idea的数据连接进行关联。
解决方法:打按照上述1、2、3操作即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值