-->
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.  [ 7 posts ] 
Author Message
 Post subject: many-to-one composite-element cascade="delete" doe
PostPosted: Thu May 12, 2005 7:55 am 
Beginner
Beginner

Joined: Tue Apr 05, 2005 12:09 pm
Posts: 48
Location: Slovakia (SK), Košice (KE)
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


Top
 Profile  
 
 Post subject: please help!
PostPosted: Fri May 13, 2005 3:03 am 
Beginner
Beginner

Joined: Tue Apr 05, 2005 12:09 pm
Posts: 48
Location: Slovakia (SK), Košice (KE)
please help!


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 4:45 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I do not read thislanguage but it seems you have a FK issue, check with your DBA to find the involved FK
Quote:
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

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 6:15 am 
Beginner
Beginner

Joined: Tue Apr 05, 2005 12:09 pm
Posts: 48
Location: Slovakia (SK), Košice (KE)
you don't need to understand my language :-), just see: http://ora-02292.ora-code.com/

KFE_JSF.SYS_C003831 is constraint in table KFE_BUSINESS_CASE_SET:
business_case_id foreign key references kfe_business_case

I could solve this problem on the server side (using on delete cascade), but I will later also use databases not having such a constraint, and then I don't want to have orphans in the KFE_BUSINESS_CASE_SET table

pls help
thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 16, 2005 10:26 am 
Beginner
Beginner

Joined: Tue Apr 05, 2005 12:09 pm
Posts: 48
Location: Slovakia (SK), Košice (KE)
please help, don't forget on me ...


Top
 Profile  
 
 Post subject: I have the same problem
PostPosted: Fri Apr 14, 2006 1:58 am 
Newbie

Joined: Fri Apr 14, 2006 1:50 am
Posts: 8
Location: Peking
this is my mapping xml:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="events.Event" table="EVENTS">
<id name="id" column="EVENT_ID">
<generator class="native"/>
</id>
<property name="date" type="timestamp" column="EVENT_DATE"/>
<property name="title"/>
<set name="eas" table="EVENT_ATTR" cascade="all-delete-orphan">
<key column="EVENT_ID"/>
<composite-element class="events.EventAttr">
<property name="attr1" type="string" length="40" column="ATTR_1"/>
<property name="attr2" type="string" length="40" column="ATTR_2"/>
<property name="attr3" type="string" length="40" column="ATTR_3"/>
</composite-element>
</set>
</class>
</hibernate-mapping>

I can insert, but cannot delete:
it report
2006-4-14 13:39:09 org.hibernate.util.JDBCExceptionReporter logExceptions
严重: ORA-02292: 违反完整约束条件 (TOR.FK59508C96F96D1A45) - 已找到子记录

there are chinese characters you may not read, but you can see ORA-02292

I'm using the default pooling in hibernate and oracle 10g 10.2.0

P.S. zdila, have you solved your problem?

_________________
bravery can set you free.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 15, 2006 12:34 am 
Regular
Regular

Joined: Wed Jul 07, 2004 2:00 pm
Posts: 64
When you said "KFE_JSF.SYS_C003831 is constraint in table KFE_BUSINESS_CASE_SET:
business_case_id foreign key references kfe_business_case", did you actually mean that it is a constraint in KFE_BUSINESS_CASE_TO_SET? 'Cause I can't see anything in your mapping from the CaseSet that directly accesses a BusinessCase.

Also, you may want to include the mapping for BusinessCase and a bit more of the SQL trace, because Hibernate should have tried deleting the KFE_BUSINESS_CASE_TO_SET records before the BusinessCase entities.

In your description, you refer to Products and LineItems, but your mappings aren't for these types. I assume that you mean that you want to delete BusinessCases when you delete the BusinessCaseSet.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.