title: hibernate - Why do i need to put child into parent collection before saving entites
body: <p>Assume i have these 2 entites </p>
  
  <pre><code>@Entity
  public class Item {
  @Id
  protected Long itemId;
  protected String title;
  protected String description;
  protected Date postdate;
  ...
  @OneToMany(mappedBy="item")
  protected Set&lt;Bid&gt; bids;
  ...
  }
  @Entity
  public class Bid {
  @Id
  protected Long bidId;
  protected Double amount;
  protected Date timestamp;
  ...
  @ManyToOne
  protected Item item;
  ...
  }
  </code></pre>
  
  <p>I have seen a lot of tutorial about hibernate but i don't understand why do i need to save child to parent collection like: itemObj.addBid(bidObj). I think the relationship is managed by the Bid so i only need to set the Item reference to Bid object like: bidObj.setItem(itemObj). And when i don't add Bid to Item collection, everything works fine. Do i need to set the reference on both side before saving? And do you know any documentations about how Hibernate scan entites, it's still vague to me how Hibernate scans entities and connect them through their relationship. Thank you.</p>