Skip to content
Advertisement

How to remove data source warnings in Spring Jpa and Intellij Idea?

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”.

Advertisement

Answer

Your setup: Spring, JPA, ORM

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.

Warning issue

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

Possible solution and further help

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.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement