title: How to disable caching in OpenJPA 2.0.1 (edit: Issues with BoneCP)
body: <p>I'm unable to disable caching in OpenJPA 2.0.1.</p>
  
  <p>I have set the following properties in my <em>persistence.xml</em>:</p>
  
  <pre><code>&lt;property name="openjpa.DataCache" value="false"/&gt;
  &lt;property name="openjpa.QueryCache" value="false"/&gt;
  &lt;property name="openjpa.jdbc.QuerySQLCache" value="false"/&gt; &lt;!-- I don't believe this is  necessary --&gt;
  </code></pre>
  
  <p>And I can see that the correct values of these properties are logged out when I start my app.</p>
  
  <p>I have created a basic entity to test this with, with a main method that simply queries the table every second. I'm creating a new EntityManager on each iteration. When I run this against an empty TEST table, and then subsequently manually insert data into test:</p>
  
  <pre><code>insert into TEST values (1,'a');
  </code></pre>
  
  <p>it never picks up on the new data (although if I re-start the program it does).</p>
  
  <pre><code>import java.util.List;    
  import javax.persistence.*;
  
  @Entity
  @Access(AccessType.PROPERTY)
  @Table(name="TEST")
  public class Test {
  
      private int id;
      private String name;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY) 
      @Column(name="ID")
      public int getId() {
          return id;
      }
      public void setId(int id) {
          this.id = id;
      }
  
      @Column(name="NAME")
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
  
      // SIMPLE TEST CASE
      public static void main(String[] args) throws Exception {
          EntityManagerFactory factory = Persistence.createEntityManagerFactory("su3", null);
          while(true) {
              EntityManager em = factory.createEntityManager();
              TypedQuery&lt;Test&gt; q = em.createQuery("select t from Test t", Test.class);
              List&lt;Test&gt; res = q.getResultList();
              for (Test t :res) {
                  System.out.println(t.getId()+", " + t.getName());
              }
              Thread.sleep(1000);
              em.close();
          }
      }
  }
  </code></pre>
  
  <p>what am I doing wrong?</p>
  
  <p><strong>EDIT1</strong>: If I create a new EntityManagerFactory <strong>inside</strong> the while loop, it works, but my understanding is that because I have set DataCache and QueryCache to false I do not need to do this, as well as it being expensive to do so.</p>
  
  <p><strong>EDIT2</strong>: I was using <a href="http://jolbox.com/" rel="nofollow">BoneCP</a> as my connection pool manager, when I reverted to using DHCP or C3P0 the problem goes away. Not sure why though...</p>
  
  <p><strong>EDIT3</strong>: This is the config I was using for BoneCP:</p>
  
  <pre><code>&lt;property name="openjpa.ConnectionDriverName" value="com.jolbox.bonecp.BoneCPDataSource"/&gt;
  &lt;property name="openjpa.ConnectionProperties" value="DriverClassName=com.mysql.jdbc.Driver,jdbcUrl=jdbc:mysql://localhost:3306/mydb,Username=xxxx,Password=yyyy,partitionCount=3"/&gt;
  </code></pre>