title: Getting old data with JPA
body: <p>I'm getting old data with JPA, even if I disable the cache. I guess is because the resource is configured to be RESOURCE_LOCAL, but I'm not sure.</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence version="2.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_2_0.xsd"&gt;
      &lt;persistence-unit name="AppPU" transaction-type="RESOURCE_LOCAL"&gt;
          &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;
          &lt;class&gt;com.myentities.User&lt;/class&gt;
          &lt;properties&gt;
              &lt;property name="javax.persistence.jdbc.url" value="jdbc:mysql://127.0.0.1:3306/mydatabase"/&gt;
              &lt;property name="javax.persistence.jdbc.password" value="*****"/&gt;
              &lt;property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/&gt;
              &lt;property name="javax.persistence.jdbc.user" value="user1"/&gt;
              &lt;property name="eclipselink.logging.level" value="FINEST"/&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>My code that is getting old info about the user:</p>
  
  <pre><code>public List&lt;User&gt; findAll(App app) {       
          getEntityManager().getTransaction().begin();        
          Query q = getEntityManager().createQuery("SELECT t1 FROM User t1 WHERE t1.app.idApp=:idApp");
          q.setParameter("idApp", app.getIdApp());
          getEntityManager().flush();
          getEntityManager().getTransaction().commit();
          List resultList = q.getResultList();        
          return resultList;
      }
  </code></pre>
  
  <p>My entity:</p>
  
  <pre><code>@Entity
  @Table(name = "user")
  @Cache (
       type=CacheType.NONE
       )
  public class User implements Serializable {
  
  // some attributtes
  
  }
  </code></pre>
  
  <p>Anybody has some idea of what is going on?</p>
  
  <h3>UPDATE 1</h3>
  
  <p>The <em>begin</em>, <em>flush</em> and <em>commit</em> methods were just acts of desperation! I know it's not needed.</p>
  
  <p>I forgot to say something <strong>important</strong>: the test I make is to add a user record <strong>direct on database console</strong> and then try to see it through my webapp, which is <strong>not showing the new user</strong>. That is the "old data" I mentioned, it only displays "old users".</p>
  
  <p>I already tried to put this on <strong>persistence.xml</strong> and I didn't see any difference in the results:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;property name="eclipselink.cache.shared.default" value="false"/&gt;
  &lt;property name="eclipselink.cache.size.default" value="0"/&gt;
  &lt;property name="eclipselink.cache.type.default" value="None"/&gt;
  </code></pre>
  
  <p>So is something else&hellip;</p>