title: JDBCTemplate multiple statements in Transaction - propagation
body: <p>I'm doing an insert + some updates inside a Transaction using <code>JDBCTemplate</code>.
  The thing is that I have to set primary key programmatically which I read from a table which keeps track of Primary keys. </p>
  
  <pre><code>public void insert(final COrder cOrder) {
      transactionTemplate.execute(new TransactionCallbackWithoutResult() {
          public void doInTransactionWithoutResult(TransactionStatus status) {
              Long cOrderId = insertOrder(cOrder);
              insertOrderLines(cOrder, cOrderId);
              insertCOrderTaxes(cOrder, cOrderId);
              updateMStorage(cOrder);
              insertMTransactions(cOrder);
          }
      });
  }
  
  public Long insertOrder(COrder o) {
      Long cOrderId = getNextId("C_ORDER");
      o.setcOrderId(cOrderId);
              ...
  }
  //the above insert methods here
  </code></pre>
  
  <p>and finally <code>getNextId()</code> which gets the next id.</p>
  
  <pre><code>public synchronized Long getNextId(final String tableName) {
          final IdHolder idHolder = new IdHolder(-1l);
          transactionTemplate.execute(new TransactionCallbackWithoutResult() {
              public void doInTransactionWithoutResult(TransactionStatus status) {
                  Long nextId = jdbcTemplate.queryForObject("SELECT CURRENTNEXT FROM AD_SEQUENCE WHERE NAME=?",
                          new String[] { tableName }, Long.class);
                  jdbcTemplate.update("UPDATE AD_SEQUENCE SET CURRENTNEXT = CURRENTNEXT + 1 WHERE NAME=?",
                          new Object[] { tableName });
                  idHolder.setId(nextId);
              }
          });
          return idHolder.getId();
      }
  </code></pre>
  
  <p><strong>Basically I want all these insertions/updates done all or none, but this getNextId() I need to commit regardless of the outer transaction(because of reserving the next primary key).</strong></p>
  
  <p>My question is, is propagation <code>PROPAGATION_REQUIRES_NEW</code> the right one for Transaction which runs in method <code>getNextId()</code>?</p>