2 Replies Latest reply on Dec 16, 2009 10:24 AM by Shervin Asgari

    CollectionOfElements and cascade delete

    Krzysiek Witkowski Newbie
      Hi!

      I have a bean property with following annotations:

      @CollectionOfElements(fetch = FetchType.EAGER)
      @JoinTable(name = "DICT_ITEM_EXT_ATTR")
      @org.hibernate.annotations.Fetch(value = org.hibernate.annotations.FetchMode.SUBSELECT)
      @Column(length = 4000)
      @org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.TRANSACTIONAL)
      public Map<String, String> getExtAttributes() {
      return extAttributes;
      }

      When I try to delete the owner of this map, i get

      java.sql.SQLException: ORA-02292: integrity constraint (DIRECT.DICITEMEXATT_DICT_ITEMS_FK) violated - child record found

      If I remove fetch = FetchType.EAGER it works fine, but I can't do that, it needs to stay as it is. Is there a way to force Hibernate to delete this child records? @Cascade( {org.hibernate.annotations.CascadeType.DELETE_ORPHAN}) is not suitable, because it's not a collection of entities.

      Thanks!
      K.