title: How do I properly set up JPA with Intellj for a postgresql database and oracle persistence provider to get rid of runtime exceptions?
body: <p>I am totally new to JPA and try to get at it with the tools provided from my University. So what I am trying to do is to set up a database carsdb with one table car and read the table from my main with a JPQL Query.</p>
  
  <p>What I did so far: 
  I created a user carsdbuser with password carsdbpw, created a postgres database carsdb, which is owned by carsdbuser, added a table car and inserted a few columns.</p>
  
  <p>I created a new Intellij project with JPA.</p>
  
  <p>I then added the postgresql jdbc drivers (I think... the file was given to us by the university) postgresql-42.2.1.jar
  as well as the oracle provider eclipslink.jar.</p>
  
  <p>I then modified the persistence.xml to look like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0"&gt;
  
  &lt;persistence-unit name="carsdb" transaction-type="RESOURCE_LOCAL"&gt;
      &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;
      &lt;class&gt;Car&lt;/class&gt;
      &lt;properties&gt;
          &lt;property name="eclipselink.jdbc.url" value="jdbc:postgresql://localhost:5432/carsdb"/&gt;
          &lt;property name="eclipselink.jdbc.driver" value="org.postgresql.Driver"/&gt;
          &lt;property name="eclipselink.jdbc.user" value="carsdbuser"/&gt;
          &lt;property name="eclipselink.jdbc.password" value="carsdbpw"/&gt;
          &lt;property name="eclipselink.target-database" value="PostgreSQL"/&gt;
          &lt;property name="eclipselink.logging.level" value="ALL"/&gt;
      &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>I created the Class Car.java:</p>
  
  <pre><code>import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  @Entity
  @Table(name = "car")
  public class Car {
  
      @Id
      @GeneratedValue(generator = "incrementor")
      private int Id;
  
      public int getId() {
          return Id;
      }
  
      public void setId(int id) {
          Id = id;
      }
      private String Name;
  
      public String getName() {
          return Name;
      }
  
      public void setName(String name) {
          Name = name;
      }
  
      @Override
      public String toString() {
          return "Car " + Id + ": Name: " + Name;
      }
  }
  </code></pre>
  
  <p>as well as the Main:</p>
  
  <pre><code>import javax.persistence.*;
  import java.util.List;
  
  public class Main {
      public static void main(String[] args){
          var factory = Persistence.createEntityManagerFactory("carsdb");
          EntityManager em = factory.createEntityManager();
  
          Query query = em.createQuery("select a from Car a");
          List&lt;Car&gt; list = query.getResultList();
          for (Car c : list) {
              System.out.println(c);
          }
      }
  }
  </code></pre>
  
  <p>Given the tutorials I am following this looks good to me, however when I run the program I get the following Error Message:</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: 
  Exception Description: Problem compiling [select a from Car a]. 
  [14, 17] The abstract schema type 'Car' is unknown.
      at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1743)
      at Main.main(Main.java:9)
  Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.7.1.v20171221-bd47e8f): org.eclipse.persistence.exceptions.JPQLException
  Exception Description: Problem compiling [select a from Car a]. 
  [14, 17] The abstract schema type 'Car' is unknown.
      at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildException(HermesParser.java:155)
      at org.eclipse.persistence.internal.jpa.jpql.HermesParser.validate(HermesParser.java:347)
      at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:278)
      at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:163)
      at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:140)
      at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:116)
      at org.eclipse.persistence.internal.jpa.EJBQueryImpl.&lt;init&gt;(EJBQueryImpl.java:102)
      at org.eclipse.persistence.internal.jpa.EJBQueryImpl.&lt;init&gt;(EJBQueryImpl.java:86)
      at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1741)
      ... 1 more
  </code></pre>
  
  <p>I tried to find some solutions with the help of some classmates and google, but did not find any solution that helped.</p>
  
  <p>I added the Database in Intellij to make sure I got the right url. The connection test works properly and I also find my car table in the Intellij database view.</p>
  
  <p>The following Question discusses a similar Issue:
  <a href="https://stackoverflow.com/questions/20193581/error-on-compiling-query-the-abstract-schema-type-entity-is-unknown">Error on compiling query: The abstract schema type &#39;entity&#39; is unknown</a></p>
  
  <p>I do however have Car in the select statement which is the case sensitive name of the entity, so I cant see how it is related to my problem.</p>