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

时间:2025-04-06 12:51:17

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 ().

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