title: Questions in one-to-many hibernate mapping
body: <p>I've checked many topics opened on stackoverflow but I didn't really get answers to my questions. Ok, let's consider this example using <strong>ArrayList</strong> :</p>
  
  <pre><code>public class Stock implements java.io.Serializable {     
      private Integer stockId;
      private String stockCode;
      private String stockName;
      private ArrayList&lt;StockDailyRecord&gt; stockDailyRecords = new ArrayList&lt;StockDailyRecord&gt;(); 
      //getter, setter and constructor
  }
  public class StockDailyRecord implements java.io.Serializable { 
      private Integer recordId;
      private Stock stock;
      private Float priceOpen;
      private Float priceClose;
      private Float priceChange;
      private Long volume;
      private Date date;
  
      //getter, setter and constructor
  }
  </code></pre>
  
  <p>So we can say association from Stock to StockDailyRecord it <strong>one-to-many</strong>. And it's what I'm trying to map in <strong>Stock.hbm.xml</strong>. I read that while mapping by the <strong>list</strong> tag, we need an <strong>index</strong>. </p>
  
  <p>So my 1st question is : is it possible to keep the <strong>index list</strong> empty??  </p>
  
  <pre><code>&lt;list name="stockDailyRecords" table="stock_daily_record" inverse="true" lazy="true" fetch="select"&gt;
      &lt;key&gt;
          &lt;column name="STOCK_ID" not-null="true" /&gt;
      &lt;/key&gt;
      &lt;list-index&gt;&lt;/list-index&gt;
      &lt;one-to-many class="com.mkyong.stock.StockDailyRecord" /&gt;
  &lt;/list&gt;
  </code></pre>
  
  <p>My second question : Let's suppose now that I add in my table <strong>STOCKDAILYRECORD</strong> ( in database ) a column called <strong>indexCol</strong>. So in Conception we would have : every Stock has a list of StockDailyRecord, ordered from 0 to x.. It means that <strong>indexCol is unique relatively to its Stock</strong>, but <strong>not unique in STOCKDAILYRECORD</strong>. Is it correct what I think?</p>
  
  <p>My third question is about a solution I found on stackoverflow here : <a href="https://stackoverflow.com/questions/3580686/hibernate-one-to-many-mapping-works-with-a-list-but-not-a-set">Hibernate one to many mapping works with a list but not a set?</a>, in the highest voted answer, it says that we can <strong>Declare the object as Collection and instantiate it as ArrayList</strong> and use <strong>bag</strong> in the xml mapping file if we want to avoid <strong>list</strong>. So is it possible to <strong>declare it ArrayList instead of Collection?</strong> Thank you a lot in advance :)</p>