Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate all objects in JPA entity
    text
    copied!<p>I'm trying to update all my 4000 Objects in <code>ProfileEntity</code> but I am getting the following exception:</p> <pre><code>javax.persistence.QueryTimeoutException: The datastore operation timed out, or the data was temporarily unavailable. </code></pre> <p>this is my code:</p> <pre><code>public synchronized static void setX4all() { em = EMF.get().createEntityManager(); Query query = em.createQuery("SELECT p FROM ProfileEntity p"); List&lt;ProfileEntity&gt; usersList = query.getResultList(); int a,b,x; for (ProfileEntity profileEntity : usersList) { a = profileEntity.getA(); b = profileEntity.getB(); x = func(a,b); profileEntity.setX(x); em.getTransaction().begin(); em.persist(profileEntity); em.getTransaction().commit(); } em.close(); } </code></pre> <p>I'm guessing that I take too long to query all of the records from <code>ProfileEntity</code>. How should I do it? </p> <ul> <li>I'm using Google App Engine so no UPDATE queries are possible. </li> </ul> <p><strong>Edited 18/10</strong><br> In this 2 days I tried:<br> using Backends as Thanos Makris suggested but got to a dead end. You can see my question <a href="https://stackoverflow.com/questions/12921874/google-app-engine-backend-servlet-not-responding">here</a>.<br> reading DataNucleus suggestion on Map-Reduce but really got lost.</p> <p>I'm looking for a different direction. Since I only going to do this update once, Maybe I can update manually every 200 objects or so.<br> Is it possible to to query for the first 200 objects and after it the second 200 objects and so on?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload