title: How to implement "delete all" for a Spring Roo Entity?
body: <p>I'm trying to delete all database entries for a Spring Roo entity. When I look at <code>*_Roo_Entity.aj</code> it seems as if there is no "delete all" method. I tried to implement it myself (<code>Licences</code> is the name of the Roo entity. Don't mind the naming. It was reverese engineered from a database and may be changed later):</p>
  
  <pre><code>public static int Licences.deleteAll() {
      return entityManager().createQuery("delete from Licences o").executeUpdate();
  }
  </code></pre>
  
  <p>It compiles just fine but when I call <code>Licences.deleteAll()</code> I get the following exception:</p>
  
  <pre><code>org.springframework.dao.InvalidDataAccessApiUsageException: Executing an update/delete query; 
  nested exception is javax.persistence.TransactionRequiredException: Executing an update/delete query (NativeException)
  </code></pre>
  
  <p>Adding <code>@Transactional</code> doesn't make a difference.</p>
  
  <p>What am I missing here? </p>
  
  <p>Is this approach completely wrong and I need to implement it like this:</p>
  
  <pre><code>    public static void Licences.deleteAll() {
          for (Licences licence : findAllLicenceses()) {
              licence.remove();
          }
      }
  </code></pre>
  
  <p>This works, but is JPA smart enough to translate this into a <code>delete from licences</code> query or will it create <code>n</code> queries?</p>