title: H2 + openJPA + JPA + Spring + apache Camel Java DSL configuration in intellij
body: <p>I am using IntelliJ IDEA. I have created an embedded H2 database and defined a table in it. My module has the JPA framework support applied. There is no spring.config xml used. I want to do the following - create a persistent H2 database on filesystem and make jpa camel component read from the database. </p>
  
  <p>The persistence.xml looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           version="1.0"
           xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"&gt;
  
  &lt;persistence-unit name="camel" transaction-type="RESOURCE_LOCAL"&gt;
      &lt;provider&gt;
          org.apache.openjpa.persistence.PersistenceProviderImpl
      &lt;/provider&gt;
      &lt;class&gt;com.workflow2015.database.model.UserEntity&lt;/class&gt;
      &lt;properties&gt;
          &lt;property name="openjpa.ConnectionURL" value="jdbc:h2:./dtbase/MYDB;AUTO_SERVER=TRUE;"/&gt;
          &lt;property name="openjpa.ConnectionDriverName" value="org.h2.Driver"/&gt;
          &lt;property name="openjpa.Log" value="DefaultLevel=WARN, Tool=WARN, SQL=WARN, Runtime=WARN"/&gt;
          &lt;property name="openjpa.RuntimeUnenhancedClasses" value="supported"/&gt;
          &lt;property name="openjpa.ConnectionUserName" value="sa"/&gt;
          &lt;property name="openjpa.ConnectionPassword" value=""/&gt;
          &lt;property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema" /&gt;
      &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p>
  My camel context gets injected with spring-boot, and I am able to run other camel components and EIP. The result that I want to achieve is the following:</p>
  
  <pre><code>from("jpa://UserEntity?consumer.query=select o from UserEntity o")
              .process(new Processor() {
                  @Override
                  public void process(Exchange exchange) throws Exception {
                   //do smthing with it
                  }
              });
  </code></pre>
  
  <p>I have UserEntity autogenerated from my DB schema into POJO. I am using maven for dependencies and the pom file has all the required dependencies. </p>
  
  <p>The issue:</p>
  
  <p>When I run the application for some reason it creates another database("testdb") with unknown schema to me and does not use the information provided in the persistence.xml</p>
  
  <pre><code>2015-06-05 22:35:00,980 [main           ] INFO  EmbeddedDatabaseFactory         Creating embedded database 'testdb'
  2015-06-05 22:35:02,138 [main           ] INFO  tainerEntityManagerFactoryBean - Building JPA container EntityManagerFactory for persistence unit 'default'
  </code></pre>
  
  <p>Why is EmbeddedDatabaseFactory creating this phantom database instead of using the one that I have created?
  Consequently I cannot use the entity that I have created and error is shown that it cannot find schema.</p>