0 Replies Latest reply on Jul 20, 2011 12:04 PM by Vijay Kamath

    Hibernate - Composite element data deleted

    Vijay Kamath Newbie

      Hello,

       

          I have faced a unique problem with my enterprise system.We find that there are some records which are deleted without any external simulation.On further probing it was found that hibernate deletes and inserts data for every update operation.We use hibernate 2.1.8 version and following the mapping we use

       

      <map name=

      "attributes" table="VEM_BUSINESS_EVENT_ATTRIBUTE"  lazy="false"  cascade="all"  outer-join="true" batch-size="400">

       

       

       

       

       

      <key column="BUSINESS_EVENT_ID"/>

       

      <index column="ATTRIBUTE_TYPE_ID" type="long"/>

       

       

       

       

      <composite-element class="BusinessEventVo$AttributeValue">

      <

      property name="value" column="ATTRIBUTE_VALUE"

      />

       

       

       

       

       

       

       

       

       

       

       

      <property name="asNumber" column="ATTRIBUTE_AS_NUMBER"

      />

       

       

       

      </composite-element

      >

       

      </map>

       

      My understanding is that due to the composite element mapping as opposed to a entity mapping,Hibernate does not maintain the life cycle of component as it does not understand uniqueness. Hence it deletes all child rows and inserts again.

      Based on this delete/insert,I feel that at certain instances,Delete happens but insert fails to happens hence leading to missing data

       

      Is this understanding right?Has anybody faced similar situations?

       

      Kindly advise