title: Hibernate Relationship Mapping/Speed up batch inserts
body: <p>I have 5 MySQL InnoDB tables: <code>Test,InputInvoice,InputLine,OutputInvoice,OutputLine</code> and each is mapped and functioning in Hibernate. I have played with using StatelessSession/Session, and JDBC batch size. I have removed any generator classes to let MySQL handle the id generation- but it is still performing quite slow. 
  Each of those tables is represented in a java class, and mapped in hibernate accordingly. Currently when it comes time to write the data out, I loop through the objects and do a <code>session.save(Object)</code> or <code>session.insert(Object)</code> if I'm using StatelessSession. I also do a flush and clear (when using Session) when my line count reaches the max jdbc batch size (50).</p>
  
  <ol>
  <li>Would it be faster if I had these in a 'parent' class that held the objects and did a <code>session.save(master)</code> instead of each one?</li>
  <li>If I had them in a master/container class, how would I map that in hibernate to reflect the relationship? The container class wouldn't actually be a table of it's own, but a relationship all based on two indexes run_id (int) and line (int).</li>
  <li>Another direction would be: How do I get Hibernate to do a multi-row insert?</li>
  </ol>