title: Difference in rolling back a statement and a transaction in JPA
body: <p>JPA Query javadoc (see <a href="http://docs.oracle.com/javaee/6/api/javax/persistence/Query.html#executeUpdate()" rel="nofollow">http://docs.oracle.com/javaee/6/api/javax/persistence/Query.html#executeUpdate()</a>) says</p>
  
  <pre><code>int executeUpdate() Execute an update or delete statement. 
  Returns: the number of entities updated or deleted 
  Throws: 
  IllegalStateException - if called for a Java Persistence query language SELECT statement or for a criteria query 
  TransactionRequiredException - if there is no transaction 
  QueryTimeoutException - if the statement execution exceeds 
    the query timeout value set and only the statement is rolled back 
  PersistenceException - if the query execution exceeds 
    the query timeout value set and the transaction is rolled back
  </code></pre>
  
  <p>What's the difference between rolling back a statemente and a transaction? I mean, rolling back a transaction is pretty obvious, it will set the transaction to rollback and all the operations will be undone. But if the statement is rolled back (since it's an update/delete/insert operation), won't the whole transaction be also rolled back in this situation?</p>
  
  <p>Was this QueryTimeoutException designed to be caught and allow the user to retry on timeout without affecting the transaction?</p>