Beginner |
|
Joined: Thu Jul 13, 2006 10:39 am Posts: 23
|
Hi all,
I have two tables submission and application. Submission.hbm file
contains <many-to-one> tag element for relationship.
How wiil I insert a new record in child table using Hibernate?.
My table structure looks like this:
-------------------------------------
Submission
submission_id raw primary key
application_id raw foriegn key
submission_name varchar
created_ts date
Application
applicaion_id raw primary key
appication_name varchar
application_path varchar
created_ts Date
--------------------------------------------------------------
my hbm files looks like this:
------------------------------------------
Submission.hbm file
<class name="Submissions" table="submission">
<id name="submissionId" type="string" unsaved-value="null" >
<column name="submission_id" sql-type="raw(16)" not-null="true"/>
</id>
<property name="subName">
<column name="submission_name" sql-type="varchar(50)" not-
null="true"/>
</property>
<property name="createdTs">
<column name="created_ts" sql-type="Date" not-null="true"/>
</property>
<many-to-one name="application" insert="false" update="false"
class="Application" column="application_id" />
</class
application.hbm file
<class name="Application" table="application">
<id name="appId" type="string" unsaved-value="null" >
<column name="application_id" sql-type="raw(16)" not-null="true"/>
</id>
<property name="appName">
<column name="application_name" sql-type="varchar2(100)" not-
null="true"/>
</property>
<property name="appPath">
<column name="application_folder_name" sql-type="varchar2
(2000)" not-null="true"/>
</property>
<property name="createdTs">
<column name="created_ts" sql-type="date" not-null="true"/>
</property>
<set name="submissions" inverse="false" cascade="all-delete-
orphan">
<key column="application_id"/>
<one-to-many class="Submissions"/>
</set>
</class>
------------------------------------------------------
My question how to insert a new record into Submission table not Application table
Can anyone please help me to solve this issue
Thanks and regards,
Sreekanth
|
|