After new update Intellij, I have red warnings in entity classes. For example:
@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "poll_answers", joinColumns = @JoinColumn(name = "poll_id"))
private Set<String> answers;
I have warning lines under "poll_answers" and "poll_id" "cannot resolve table/column" and offers me press "assign data source".
Since your Spring project uses JPA and you are defining object-relational-mappings (ORM) using annotations:
@JoinTable(name = "poll_answers", joinColumns = @JoinColumn(name = "poll_id"))
IntelliJ is intelligent and tries to validate the specified tables and columns against the database .
You can get an idea of the magic from this tutorial , although the topic is slightly going into another direction.
You did not really provide the settings/setup (JPA Facet, etc.) that you are using within your IntelliJ project. It would be ideal if you can provide more information or a screenshot.
Since you apparently have no database/data-source assigned within your IntelliJ Database Tools window, the above explained validation fails and the reported warning is shown:
cannot resolve table/column
A solution may be, to add the Data Source as the warning popup suggests already.
Maybe this tutorial can help you to setup a new Data Source within IntelliJ Database Tools . You can use your JDBC connetion-string (starting with jdbc://
) from your mentioned application.properties
to configure your database-connection.
In my comment to your question I also pointed you to this answer here, which pictorally describes how to Assign Data Sources via the IntelliJ menu: View -> Tool Windows -> Persistence .
If you want to ignore such warnings without having to configure a data-source inside IntelliJ you can do that by removing the particular inspection in Settings under : Editor > Inspections
.
The proper selector should be under: JPA > Unresolved database references in annotations
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.