title: Modifying Query Result in JPA
body: <pre><code>EntityManager em = EMF.get().createEntityManager();
  EntityTransaction tx = null;
  
  List&lt;Profile&gt; list = null;
  Query q = null;
  
  try{
      tx = em.getTransaction();
      tx.begin();
  
      q = em.createNamedQuery("Profile.getRandomProfile");
      q.setParameter("random", Math.random());
      q.setMaxResults(8);
      list = (List&lt;Profile&gt;) q.getResultList();
  
      if (list != null){
          Collections.shuffle(list);
      }
  
      tx.commit();
  
  } catch(NoResultException ex){
      System.out.println("ERROR CATCHED: " +ex.getMessage());
      if(tx != null &amp;&amp; tx.isActive())
          tx.rollback();
  } catch(Exception e){
      e.printStackTrace();
  }
  finally{
      em.close();
  }
  </code></pre>
  
  <p>Shuffling the list have error:</p>
  
  <pre><code>java.lang.UnsupportedOperationException: Query result sets are not modifiable
  </code></pre>
  
  <p>How to overcome the problem?</p>