How do I add data source in persistence.xml so that IntelliJ IDEA sees it?

user1094931 picture user1094931 · Dec 14, 2011 · Viewed 7.1k times · Source

How do I add data source in persistence.xml so that IntelliJ IDEA sees it ?

I have little desktop application (which works as I want it to) that has following persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="reportingPU" transaction-type="RESOURCE_LOCAL">
        <provider>oracle.toplink.essentials.PersistenceProvider</provider>
        <class>com.test.data.Company</class>
        <properties>
            <property name="toplink.jdbc.user" value="SA"/>
            <property name="toplink.jdbc.password" value=""/>
            <property name="toplink.jdbc.url" value="jdbc:hsqldb:file:ReportingDB"/>
            <property name="toplink.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
            <property name="toplink.target-database" value="HSQL"/>
        </properties>
    </persistence-unit>
</persistence>

When I open class Company.java which looks like

@Entity
@Table(name = "COMPANY")
public class Company implements Serializable{

    @Id
    private Long id;
    @Column(name = "NAME")
    private String name;
}

IDEA underscores "COMPANY" and "NAME" saying data source is not defined. And yes, I don't have it in data source column if I open JPA module configuration.

This article says I should add jta-data-source tag to persistence.xml but it doesn't make datasource show up in JPA module configuration view.

I'm confused :(

Answer

expert picture expert · Dec 14, 2011

Go to Tool/Data Sources menu. It will let you add new datasource based on information in properties tag of your persistence.xml. After that you'll be able to select it in JPA module configuration window.