Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0
Hi. I have 3 tables in many-to-many relation like in
http://www.hibernate.org/hib_docs/v3/re ... derproduct
I'd like to automaticaly delete relevant rows in LineItem table when i delete row from Product table. I've added cascade="delete" to the many-to-one relation, but it doesn't work. This is my configuration:
Code:
<hibernate-mapping>
<class name="com.kovine.kfe.dao.BusinessCaseSet" table="KFE_BUSINESS_CASE_SET">
<id name="id" unsaved-value="null">
<column name="BUSINESS_CASE_SET_ID" not-null="true" sql-type="NUMBER"/>
<generator class="sequence">
<param name="sequence">KFE_BUSINESS_CASE_SET_ID_SEQ</param>
</generator>
</id>
<property name="name" column="BUSINESS_CASE_SET_NAME" length="100" not-null="true" />
<property name="inactiveTabBgColor" column="INACTIVE_TAB_BG_COLOR" not-null="true" />
<property name="inactiveTabColor" column="INACTIVE_TAB_COLOR" not-null="true" />
<property name="activeTabBgColor" column="ACTIVE_TAB_BG_COLOR" not-null="true" />
<property name="activeTabColor" column="ACTIVE_TAB_COLOR" not-null="true" />
<set name="sortedBusinessCases" table="KFE_BUSINESS_CASE_TO_SET" order-by="SORT_ORDER" cascade="delete">
<key column="business_case_set_id" />
<composite-element class="com.kovine.kfe.dao.SortedBusinessCase">
<property name="sortOrder" column="SORT_ORDER" />
<many-to-one name="businessCase" column="business_case_id" class="com.kovine.kfe.dao.BusinessCase" cascade="delete"/>
</composite-element>
</set>
</class>
</hibernate-mapping>
Code:
DEBUG SQL - delete from KFE_BUSINESS_CASE where BUSINESS_CASE_ID=?
WARN JDBCExceptionReporter - SQL Error: 2292, SQLState: 23000
ERROR JDBCExceptionReporter - ORA-02292: narušené referenčné obmedzenie (KFE_JSF.SYS_C003831) - nenašiel sa kľúč potomka
WARN JDBCExceptionReporter - SQL Error: 2292, SQLState: 23000
ERROR JDBCExceptionReporter - ORA-02292: narušené referenčné obmedzenie (KFE_JSF.SYS_C003831) - nenašiel sa kľúč potomka
ERROR AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:161)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:71)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:66)
at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:130)
at org.hibernate.persister.entity.BasicEntityPersister.delete(BasicEntityPersister.java:2019)
at org.hibernate.persister.entity.BasicEntityPersister.delete(BasicEntityPersister.java:2184)
at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:59)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:669)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:293)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at com.kovine.kfe.beans.BusinessCaseList.delete(BusinessCaseList.java:109)
Please help
Thanks in advance
Martin