-->
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.  [ 1 post ] 
Author Message
 Post subject: How to inset a value in to many-to-one tag using Hibernate
PostPosted: Mon Jul 17, 2006 5:27 am 
Beginner
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.