Beginner |
|
Joined: Thu Jul 13, 2006 10:39 am Posts: 23
|
Hi all,
I am very new to Hibernate.I have problem in Hibernate while inserting a data into a table.
My table structure look like :
----------------------------
Val_status:
-------------
Val_status_id raw primary key
Val_session_id raw foriegn key
username varchar
created_ts date
las_modified_ts date
----------------------------------
Val_session:
-----------------------
Val_session_id raw primary key
val_context varchar
user name
---------------------------------------------------
My hbm file look like this
----------------------------------------
ValStatus.hbm.xml
******************
<class name="ValStatus" table="val_status">
<id name="valStatusId" type="string" unsaved-value="null" >
<column name="val_status_id" sql-type="raw(16)" not-null="true"/>
</id>
<property name="valContext">
<column name="val_context" sql-type="varchar2(3)" not-null="true"/>
</property>
<property name="userName">
<column name="username" sql-type="varchar2(50)" not-null="true"/>
</property>
<property name="createdTs" >
<column name="created_ts" sql-type="date" not-null="true"/>
</property>
<property name="lastModifiedTs" >
<column name="last_modified_ts" sql-type="date" not-null="true"/>
</property>
<many-to-one name="Session" insert="false" update="false" class="ValSession" column="val_session_id"/>
</class>
-------------------------------------------------------------------------
ValSession.hbm.xml
************************
<class name="ValSession" table="val_session">
<id name="valSessionId" type="string" unsaved-value="null" >
<column name="val_session_id" sql-type="raw(16)" not-null="true"/>
</id>
<property name="userName">
<column name="username" sql-type="varchar2(50)" not-null="true"/>
</property>
<property name="createdTs" >
<column name="created_ts" sql-type="date" not-null="true"/>
</property>
<property name="lastModifiedTs" >
<set name="status" inverse="false" cascade="all-delete-orphan">
<key column="val_session_id"/>
<one-to-many class="ValStatus"/>
</set>
</class>
--------------------------------------------------------------------------
I need to insert a value into val_session_id(Val_status table).
My question is how to insert a value into val_seesion_id in Val_status table
I do't want to insert any value into val_session table.
Could anyone hel me to solve this problem
Please do favour with me
Thanks and Regards,
Sreekanth
|
|