-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: ORA-02291: integrity constraint (AMS.SYS_C0059678) violated
PostPosted: Fri Apr 16, 2010 7:40 am 
Newbie

Joined: Sun Mar 01, 2009 11:11 pm
Posts: 9
When I try to update an Object which Has many to one relation and cascade=all,
I get the Error
ORA-02291: integrity constraint (AMS.SYS_C0059678) violated - parent key not found

My
Code:
<hibernate-mapping>
   <class name="hmil.service.basic.model.ServiceDet" table="RDMNDET_TB">
      <composite-id>
      <key-property name="MNDET_CMPN_NO"  type="java.lang.String"></key-property>
      <key-property name="MNDET_CORP_NO"  type="java.lang.String"></key-property>
      <key-property name="MNDET_DLR_NO"  type="java.lang.String"></key-property>
      <key-property name="MNDET_SCTN_ID"  type="long"></key-property>
      <key-property name="MNDET_YEAR_MONTH"  type="java.lang.String"></key-property>
      </composite-id>      

      <property name="MNDET_WORKING_DAYS" type="long" />
      <property name="MNDET_MECH_BAY" type="long" />
      <property name="MNDET_BODY_BAY" type="long" />
      
    more columns.....

      <many-to-one name="MNDET_DLR"  class="hmil.com.dlr.model.DealerOrg" fetch="join" cascade="none" insert="false" update="false">
         <column name="MNDET_CMPN_NO" />
         <column name="MNDET_CORP_NO" />
         <column name="MNDET_DLR_NO" />
         <column name="MNDET_SCTN_ID" />
      </many-to-one>
      
       <many-to-one name="MNDET_ATD" class="hmil.service.basic.model.AdvTechDet"     cascade="all" column="MNDET_ATDET_ID" fetch="join"></many-to-one>
       <many-to-one name="MNDET_ROD" class="hmil.service.basic.model.RepairOrderDet" cascade="all" column="MNDET_RODET_ID" fetch="join"></many-to-one>
      <many-to-one name="MNDET_EPD" class="hmil.service.basic.model.DepDet"         cascade="all" column="MNDET_EPDET_ID" fetch="join"></many-to-one>
      <many-to-one name="MNDET_CSI" class="hmil.service.basic.model.CSIDet"         cascade="all" column="MNDET_CSI_ID" fetch="join"></many-to-one>
       <many-to-one name="MNDET_EMP" class="hmil.com.general.model.Employee"   cascade="none" column="MNDET_EMP_ID"  fetch="join" insert="false" update="false" ></many-to-one>
   </class>
</hibernate-mapping>


And My JAVA code is

Code:
                       HibernateUtils.currentSession().beginTransaction();
                                 srvDetObj = new ServiceDet();
            //call Setter methods

            //Repair Order
            RepairOrderDet roDet = new RepairOrderDet();
            roDet.setRODET_CMPN_NO(Common.CMPN_NO);
                                // more setter methods
            

                                //Advisor Technician
            AdvTechDet atDet = new AdvTechDet();
            atDet.setATDET_CMPN_NO(Common.CMPN_NO);
                 // more setter methods   

            //Dealer Enhancement Program
            DepDet depDet = new DepDet();
            depDet.setEPDET_CMPN_NO(Common.CMPN_NO);
                                // more setter methods            
            
            //CSI
            CSIDet csiDet = new CSIDet();
            csiDet.setCSIDT_CMPN_NO(Common.CMPN_NO);
                                // more setter methods            
         
            srvDetObj.setMNDET_ROD(roDet);
            srvDetObj.setMNDET_ATD(atDet);
            srvDetObj.setMNDET_EPD(depDet);
            srvDetObj.setMNDET_CSI(csiDet);
            HibernateUtils.currentSession().save(srvDetObj);
            HibernateUtils.currentSession().getTransaction().commit();


This Save was working earlier, but not sure what changes I did, now it does not work.

The strange thing is even if i change the save to update or save or update, it always tries to insert the records. and then DB error is thrown as unique key is violated
Any help is appreciated.


Top
 Profile  
 
 Post subject: Re: ORA-02291: integrity constraint (AMS.SYS_C0059678) violated
PostPosted: Fri Apr 16, 2010 8:07 am 
Newbie

Joined: Sun Mar 01, 2009 11:11 pm
Posts: 9
Ignore this post it was a silly mistake in constraints in DB


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.