not able to delete
Hi I am able to add record but not able to delete record.
It gives the following error:
[ERROR] 2010-02-20 13:38:16 (JDBCExceptionReporter.java:logExceptions:78) ORA-02292: integrity constraint (BANKNET.FK_DDA_DEAL_ADVISOR) violated - child record found
[ERROR] 2010-02-20 13:38:16 (AbstractFlushingEventListener.java:performExecutions:301)
Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: could not delete: [com.bofa.crme.dda.domain.ManualDDAData#10041]
Here are my mapping files:
Child table:
<hibernate-mapping>
<class name="com.bofa.crme.dda.domain.DealAdvisor" table="DDA_DEAL_ADVISOR" schema="BANKNET">
<composite-id name="comp_id" class="com.bofa.crme.dda.domain.DealAdvisorPK">
<key-property name="advisorNm" column="ADVISOR_NM" type="java.lang.String" length="100" access="property"/>
<key-many-to-one name="ddaDeal" column="DDA_DEAL_NO" class="com.bofa.crme.dda.domain.ManualDDAData" />
</composite-id>
<property name="modifiedBy" column="MODIFIED_BY" type="java.lang.String" update="true" insert="true" access="property" />
<property name="modifiedDt" column="MODIFIED_DATE" type="java.util.Date" update="true" insert="true" access="property"/>
</class>
</hibernate-mapping>
Parent table:
<hibernate-mapping>
<class name="com.bofa.crme.dda.domain.ManualDDAData" table="DDA_DEAL" schema="BANKNET" >
<id name="ddaDealNumber" column="DDA_DEAL_NO" type="java.lang.Long">
<generator class="sequence">
<param name="sequence">BANKNET.DDA_DEAL_ID_SEQ</param>
</generator>
</id>
<property name="clientGCI" type="java.lang.String" update="true" insert="true" access="property" column="GCI" />
<set name="dealAdvisors" inverse="true" cascade="all,all-delete-orphan" lazy="false">
<key column="DDA_DEAL_NO" not-null="true" on-d开发者_运维知识库elete="cascade"/>
<one-to-many class="com.bofa.crme.dda.domain.DealAdvisor" />
</set>
</class>
</hibernate-mapping>
Anyone know why it is not working ?
are you sure you defined the on-delete constraint in your database correctly? heres a good explaination what the on-delete="cascade" does http://eddii.wordpress.com/2006/11/16/hibernate-on-deletecascade-performance/
精彩评论