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: cascading
PostPosted: Fri Aug 19, 2005 11:40 am 
Newbie

Joined: Tue Aug 02, 2005 1:40 pm
Posts: 16
Location: US
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Why is hibernate generating Update to the child tables, where i have a one-to-many problem?

I have create an addRules method to add the rules to the parent ...

Also I have the cascade="all" and inverse="true"

Hibernate version:
hibernate 3.0.5
Mapping documents:
<class name="model.Menu" table="menu_level" >
<id name="levelId" type="integer" unsaved-value="0">
<column name="LEVEL_ID" sql-type="number(10)" not-null="true" />
<generator class="assigned"/>
</id>

<property name="name" type="string">
<column name="NAME" length="6" not-null="true" />
</property>
<bag name="rules" cascade="all" inverse="true" lazy="false" >
<key column="PARENT_LEVEL_ID"/>

<one-to-many class="model.Rule" />

</bag>
</class>




<class name="model.Rule" table="ice_rule" >
<id
column="rule_id"
type="integer"
name="ruleId" unsaved-value="0">
<generator
class="assigned">
</generator>
</id>
<property
name="reasonId"
column="REASON_ID" />
<property
name="ruleTypeId"
column="RULE_TYPE_ID" />

<many-to-one name="menu" class="model.Menu" column="parent_level_id" insert="true" update="true">
</many-to-one>

</class>

Code between sessionFactory.openSession() and session.close():
Menu m = new Menu();
m.setLevelId=(99999);
m.setName=("test");
Rule r = new Rule();

r.setRuleId(9999);
r.setRuleTypeId(0);
r.setReasonId(0);

m.addRule(r);
dao.save(m);

Full stack trace of any exception that occurs:

Name and version of the database you are using:
Oracle 8i
The generated SQL (show_sql=true):
Hibernate: insert into menu_level (NAME, DATASET_ID, active_status, CHNG_DATE, CHNG_USER, CLASS_ID, LOCKED_STATUS, BLACKBIRD, COMPLETE_STATUS, SOURCE_ID, web, WEB_COMPLIANT, BUNDLE, GROUP_ID, IGNORE_TYPES, EXTERNAL_ID, LEVEL_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: update display_name set NAME=? where DISPLAY_NAME_ID=?
Hibernate: update ice_rule set PARENT_TYPE_ID=?, REASON_ID=?, RULE_TYPE_ID=?, behavior_id=?, ice_only=?, rule_date=?, parent_level_id=? where rule_id=?
Hibernate: update rule_dm set DM_CID=?, CHILD_TYPE_ID=?, rule_type_id=? where rule_id=?
Hibernate: update ice_rule set PARENT_TYPE_ID=?, REASON_ID=?, RULE_TYPE_ID=?, behavior_id=?, ice_only=?, rule_date=?, parent_level_id=? where rule_id=?
Hibernate: update rule_dm set DM_CID=?, CHILD_TYPE_ID=?, rule_type_id=? where rule_id=?
Hibernate: update rule_dm set RULE_ID=null where RULE_ID=?
Hibernate: update rule_dm set RULE_ID=null where RULE_ID=?
Hibernate: insert into ice_restrictions (ID, restriction_type, restriction, TYPE_ID) values (?, ?, ?, ?)
Hibernate: insert into ice_restrictions (ID, restriction_type, restriction, TYPE_ID) values (?, ?, ?, ?)
Hibernate: insert into ice_restrictions (ID, restriction_type, restriction, TYPE_ID) values (?, ?, ?, ?)
Hibernate: update rule_dm set RULE_ID=? where rule_id=?
Hibernate: update rule_dm set RULE_ID=? where rule_id=?
Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: Here is the answer
PostPosted: Fri Aug 19, 2005 1:16 pm 
Newbie

Joined: Tue Aug 02, 2005 1:40 pm
Posts: 16
Location: US
for the child set

<class name="model.Rule" table="ice_rule" >
<id
column="rule_id"
type="integer"
name="ruleId" unsaved-value="any">

unsaved value to any and the thing works :-D


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.