-->
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: Child record not saved in one-to-many hibernate
PostPosted: Thu Jun 01, 2006 1:35 pm 
Newbie

Joined: Thu Jun 01, 2006 1:28 pm
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:2.0

Mapping documents: Parent
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping default-cascade="none" default-access="property" auto-import="true">
<class name="com.freightdesk.intelliagent.model.ControlAgentModel" table="IA_CONTROLAGENT">
<id name="controlAgentId" type="long">
<column name="CONTROLAGENTID" sql-type="number" not-null="true"/>
<generator class="sequence">
<param name="sequence">IA_CONTROLAGENTID</param>
</generator>
</id>
<property name="controlAgentName">
<column name="CONTROLAGENTNAME" />
</property>
<property name="controlAgentDesc">
<column name="CONTROLAGENTDESC" />
</property>
<property name="defaultAlertSubject">
<column name="DEFAULTALERTSUBJECT" />
</property>
<property name="defaultAlertTemplate">
<column name="DEFAULTALERTTEMPLATE" />
</property>
<property name="status"/>
<property name="lastUpdateUserId"/>
<property name="lastUpdateTimestamp"/>
<property name="createUserId"/>
<property name="createTimestamp" insert="false" />
<property name="domainName"/>
<property name="lastExecutedTimestamp">
<column name="LASTEXECUTEDTIME" />
</property>
<bag name="alertList" cascade="all-delete-orphan" inverse="true" >
<key> <column name="CONTROLAGENTID" /></key>
<one-to-many class="com.freightdesk.intelliagent.model.AlertActionModel"/>
</bag>
<set name="test" table="IA_DBACTION" inverse="false" cascade="all" >
<key column="CONTROLAGENTID" />
<one-to-many class="com.freightdesk.intelliagent.model.DBActionModel" />
</set>
<bag name="javaActionList" cascade="all" inverse="true">
<key column="CONTROLAGENTID"/>
<one-to-many class="com.freightdesk.intelliagent.model.JavaActionModel"/>
</bag>
<bag name="nextControlAgentList" cascade="all" inverse="true" >
<key column="CONTROLAGENTID"/>
<one-to-many class="com.freightdesk.intelliagent.model.WorkFlowAgentModel"/>
</bag>
</class>
</hibernate-mapping>



Child

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping default-cascade="none" default-access="property" auto-import="true">
<class name="com.freightdesk.intelliagent.model.DBActionModel" table="IA_DBACTION">
<id name="intelliAgentDBActionId" type="long">
<column name="DBACTIONID" sql-type="number" not-null="true"/>
<generator class="sequence">
<param name="sequence">IA_DBACTIONID</param>
</generator>
</id>
<!--<property name="agentID">
<column name="CONTROLAGENTID" />
</property>-->
<property name="intelliAgentDBActionDML">
<column name="DBACTIONDML" />
</property>
<property name="sequenceName" />
<property name="allowMultiple">
<column name="ALLOWMULTIPLERECORDS" />
</property>
<property name="secondaryDML" />
<property name="status"/>
<property name="lastUpdateUserId"/>
<property name="lastUpdateTimestamp"/>
<property name="createUserId"/>
<property name="createTimestamp" insert="false" />
<property name="domainName"/>
<many-to-one name="controlAgent"
class="com.freightdesk.intelliagent.model.ControlAgentModel"
column="CONTROLAGENTID" insert="true" update="true" />
</class>
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close(): Transaction t = session.beginTransaction();
DBActionModel dbModel = new DBActionModel();
dbModel.setBaseProperties("SYSTEM",new Timestamp(System.currentTimeMillis()),"SYSTEM",new Timestamp(System.currentTimeMillis()),"SYSTEM");
dbModel.setIntelliAgentDBActionDML("AAAAAAAAA");
dbModel.setControlAgent(controlAgentModel);
controlAgentModel.getTest().add(dbModel);
session.save(controlAgentModel);
t.commit();


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):

Debug level Hibernate log excerpt:

excute first insert on parent and then try to update child .

Insert on child never called ,First the insert on parent and then update.
Please help.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 5:27 pm 
Regular
Regular

Joined: Mon May 22, 2006 2:30 pm
Posts: 74
Try adding not-null="true" to the key definition for the child.

<set name="test" table="IA_DBACTION" inverse="false" cascade="all" >
<key column="CONTROLAGENTID" />

should become
<key column="CONTROLAGENTID" not-null="true" />


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.