title: Not able to delete data from mapping table in hibernate
body: <p>I have 2 entity One is Header and another one is Items </p>
  
  <p>Header has many items </p>
  
  <p>Header code as below</p>
  
  <pre><code>@Entity
  public class Headertable {
  
    @Id
    @GeneratedValue
    private int headerId;
  
    private String headerText;
  
    @OneToMany(mappedBy="itemId.header",cascade=CascadeType.ALL,fetch=FetchType.EAGER)
    private List&lt;Items&gt; items = new ArrayList&lt;Items&gt;();
    ...
    getter and setters for these
  </code></pre>
  
  <p>and Item table as below</p>
  
  <pre><code>@Entity
  public class Items {
  
    @EmbeddedId
    private ItemId itemId;
  
    private String itemData;
    .... getter and setters for these
  </code></pre>
  
  <p>Item table id class</p>
  
  <pre><code>@Embeddable
  public class ItemId implements Serializable{
  
    @ManyToOne
    private Headertable header;
  
    private int itemId;
    ...setter and getters
  </code></pre>
  
  <p>Here is the test code to delete one item from the Header as below</p>
  
  <pre><code>Session session = this.sessionFactory.openSession();
      session.beginTransaction();
      Headertable header = (Headertable) session.get(Headertable.class, 1);
  
      Iterator&lt;Items&gt; iterator = header.getItems().iterator();
      while( iterator.hasNext() )
      {
        Items items = iterator.next();
        if( items.getItemData().equals("chiru"))
        {
          iterator.remove();
        }
      }
      session.saveOrUpdate(header);
      Transaction transaction = session.getTransaction();
      transaction.commit();
  </code></pre>