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.