title: JPA updating multiple rows and tables
body: <p>i need to update multiple rows in Table a and it seems ok to use the object oriented approach by using a for loop and doing a merge. </p>
  
  <pre><code>...
  // get list and assign columns to be updated
  ...
  for (MyEntity e : entityList) {
     em.merge(e);
  }
  ..
  </code></pre>
  
  <p>this approach also enables me to update other tables (as other property pf MyEntity).
  on one of the questions posted here <a href="https://stackoverflow.com/questions/4069513/updating-multiple-rows-using-jpa">updating multiple rows using JPA</a> , the second option which uses a namedQuery to update seems to be faster. However how will the update be implemented if i need to batch update multiple tables as well?</p>
  
  <p>i have tried:</p>
  
  <pre><code>@NamedQuery(name="Agent.updateAccountStatusByTree",
          query="UPDATE com.sample.core.data.Agent a "
              + "INNER JOIN com.sample.core.data.Player p "
              + "ON a.player.id = p.id "
              + "SET a.accountStatus=:accountStatus, p.status=:accountStatus "
              + "WHERE a.site.id=:siteId and a.agentTree like :agentTree")})
  </code></pre>
  
  <p>however this throws a:</p>
  
  <pre><code>org.hibernate.hql.ast.QuerySyntaxException: expecting "set", found 'INNER'
  </code></pre>
  
  <p>another option which i tried is:</p>
  
  <pre><code> @NamedQuery(name="Agent.updateAccountStatusByTree",
          query="update com.sample.core.data.Agent a "
              + "set a.accountStatus=:accountStatus, a.player.status=:playerStatus "
              + "where a.site.id=:siteId and a.agentTree like :agentTree")})
  </code></pre>
  
  <p>since i already have a refer to the other table, however this generates an invalid query throwing a sql grammar exception... is there any other way to achieve this?</p>
  
  <p>Thanks.</p>