title: Batch insert mode with hibernate and oracle: seems to be dropping back to slow mode silently
body: <p>I'm trying to get a batch insert working with Hibernate into Oracle, according to what i've read here: <a href="http://docs.jboss.org/hibernate/core/3.3/reference/en/html/batch.html" rel="nofollow noreferrer">http://docs.jboss.org/hibernate/core/3.3/reference/en/html/batch.html</a> , but with my benchmarking it doesn't seem any faster than before.</p>
  
  <p>Can anyone suggest a way to prove whether hibernate is using batch mode or not? I hear that there are numerous reasons why it may silently drop into normal mode (eg associations and generated ids) so is there some way to find out why it has gone non-batch?</p>
  
  <p>My hibernate.cfg.xml contains this line which i believe is all i need to enable batch mode:</p>
  
  <pre><code>&lt;property name="jdbc.batch_size"&gt;50&lt;/property&gt;
  </code></pre>
  
  <p>My insert code looks like this:</p>
  
  <pre><code>List&lt;LogEntry&gt; entries = ..a list of 100 LogEntry data classes...
  Session sess = sessionFactory.getCurrentSession();
  for(LogEntry e : entries) {
    sess.save(e);
  }
  sess.flush();
  sess.clear();
  </code></pre>
  
  <p>My 'logentry' class has no associations, the only interesting field is the id:</p>
  
  <pre><code>@Entity
  @Table(name="log_entries")
  public class LogEntry {
    @Id @GeneratedValue
    public Long id;
    ..other fields - strings and ints...
  </code></pre>
  
  <p>However, since it is oracle, i believe the @GeneratedValue will use the <a href="http://www.roseindia.net/hibernate/hibernateidgeneratorelement.shtml" rel="nofollow noreferrer">sequence generator</a>. And i believe that only the 'identity' generator will stop bulk inserts.</p>
  
  <p>So if anyone can explain why it isn't running in batch mode, or how i can find out for sure if it is or isn't in batch mode, or find out why hibernate is silently dropping back to slow mode, i'd be most grateful.</p>
  
  <p>Thanks</p>