Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9154803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:29:16+00:00 2026-06-17T12:29:16+00:00

I have a Spring project for a small web app set up in Intellij

  • 0

I have a Spring project for a small web app set up in Intellij IDEA.

It uses JPA on top of Hibernate for the persistence layer. The datasource (MySQL) is defined in Spring application context :

    <!-- Values are configured via the property override -->
    <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" >
        <property name="driverClassName" value=""/>
        <property name="url" value=""/>
        <property name="username" value=""/>
        <property name="password" value=""/>
    </bean>

The actual value are read from a properties file and injected at runtime by Spring using the property-override mechanism.

And then the datasource is injected into the entity manager factory in the same application context:

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="myDataSource"/>
    </bean>

Finally the entity manager injected into the DAOs using an annotation:

/**
 * Shared, thread-safe proxy for the actual transactional EntityManager
 */
@PersistenceContext
private EntityManager em;

It all works fine when I build and deploy it to Tomcat, but Intellij’s JPA validation doesn’t seem to understand where to get the datasource from.

In my entities, the tables’ names and columns’ names are underlined in red and the validation message is “cannot resolve table” or “cannot resolve column”:

@Entity
@Table(name = "domain")
public class Domain extends AbstractAgendaEntity {

Int this example, it’s the "domain" part that is not considered valid.

I have manually configured my database in the “Database” tool window, I can see my tables and perform SQL queries in the console.

How can I tell Intellij to use this datasource to resolve table names for my JPA entities?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:29:17+00:00Added an answer on June 17, 2026 at 12:29 pm

    I finally found out how to do this.

    The key is the “persistence” tool window. Apparently it is made available after you add the JPA facet, but is a separate tool window.

    To open it : menu “view” -> Tool Windows -> Persistence

    In this window you see your application with the different persistence related elements (I see persistence.xml, entityManagerFactory from Spring context, and myUnit which I don’t know where it comes from.

    Here you can right-click on any element and choose “Assign data source”.
    enter image description here

    This opens a pop-up dialog with a small table containing you persistence elements on the left column and the data source assigned to it on the right column. You can assign a datasource from the “Database” window in there, so I picked the datasource I had configured for my MySQL DB and voilà, the validation errors went away.

    But if I enter a wrong table or column name, I still get an error, which is pretty neat.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Spring 3.0.x web project that is displaying a page of links
I have a project with spring and hibernate in GWT, I am using below
I have Maven project with Hibernate and Spring framework. I want Hibernate to create
I have a small console app containing a web server written in c#. When
I am using Hibernate and Spring on a small personal project. Well, still a
i have a small maven project with <artifactId>spring-core</artifactId> <artifactId>spring-test</artifactId> <artifactId>spring-beans</artifactId> <artifactId>spring-context</artifactId> <artifactId>spring-aop</artifactId> <artifactId>spring-context-support</artifactId> <artifactId>spring-tx</artifactId>
We have a small project with some heavy-weight dependencies (e.g. Spring) of which we
Currently I am working on a project with Spring web-service, hibernate and JAXb. 1)
I have a Spring Project with Wicket. I can successfully inject Services in Wicket
I have a Spring Roo project and I use mvn jetty:run to run my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.