您好我可以添加记录但无法删除记录。
它出现以下错误:
[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]
以下是我的映射文件:
子表:
<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>
父表:
<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-delete="cascade"/>
<one-to-many class="com.bofa.crme.dda.domain.DealAdvisor" />
</set>
</class>
</hibernate-mapping>
任何人都知道它为什么不起作用?
答案 0 :(得分:0)
您确定在数据库中正确定义了on-delete约束吗?下面是一个很好的解释:on-delete =“cascade”http://eddii.wordpress.com/2006/11/16/hibernate-on-deletecascade-performance/