-->
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.  [ 5 posts ] 
Author Message
 Post subject: saving parent key in a child table from a jsp page
PostPosted: Wed May 11, 2005 7:16 am 
Newbie

Joined: Thu Apr 14, 2005 9:58 pm
Posts: 7
Hello,

Hibernate version: 3.0.1

Mapping documents: Register.hbm.xml

Name and version of the database you are using: My SQL 4.1


Register.hbm.xml

[code]
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.evite.beans">
<class name="com.evite.beans.Register" lazy = "false" table="REGISTER" dynamic-update="false" dynamic-insert="false" select-before-update="false">
<id name="userid" column="USER_ID" type="string" >
<generator class="assigned"/>
</id>

<many-to-one name="address" class="com.evite.beans.Address" column = "ADDRESS_ID" cascade="delete" unique="true"/>
<property name="firstname" type="string" update="true" insert="true" column="FIRSTNAME" not-null="true" unique="false" optimistic-lock="true" lazy="false"/>
<property name="lastname" type="string" update="true" insert="true" column="LASTNAME" not-null="true" unique="false" optimistic-lock="true" lazy="false"/>
<property name="password" type="string" update="true" insert="true" column="PASSWORD" not-null="true" unique="false" optimistic-lock="true" lazy="false"/>
<property name="email" type="string" update="true" insert="true" column="EMAIL" not-null="true" unique="true" optimistic-lock="true" lazy="false"/>
<property name="language" type="string" update="true" insert="true" column="LANGUAGE" not-null="false" unique="false" optimistic-lock="true" lazy="false"/>
<set name="contacts" table="CONTACTS" lazy="true" inverse="false" cascade="all" sort="unsorted" optimistic-lock="true" embed-xml="true">
<key column="USER_ID" on-delete="noaction"/>
<one-to-many class="com.evite.beans.Contacts" not-found="exception" embed-xml="true"/>
</set>
<set name="events" table="EVENT" lazy="true" inverse="false" cascade="all" sort="unsorted" optimistic-lock="true" embed-xml="true">
<key column="USER_ID" on-delete="noaction"/>
<one-to-many class="com.evite.beans.Event" not-found="exception" embed-xml="true"/>
</set>

</class>
</hibernate-mapping>
[code]

I am creating a struts application wherein a person logs in and stores his list of events in the Event table. His personal information is stored in the Register table. First time user goes in and registers - his userid is the primary key for the register table. Now he comes back and logs in again and adds events to his list. At the time of saving the event, userid is not being added to the table.

How do I do that? why is the mapping not causing the value to be picked up from the register table as per his login? hw do i acheive this?

Help me someone,
Thanks,
Manju[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 11, 2005 9:48 am 
Regular
Regular

Joined: Mon Oct 06, 2003 7:17 am
Posts: 58
Location: Switzerland
Do you also update the register object after storing the events? Because the register is responsible for the relationship in the db.

Reto


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 11, 2005 2:21 pm 
Newbie

Joined: Thu Apr 14, 2005 9:58 pm
Posts: 7
Hello,
No I am not.
--Manju


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 11, 2005 2:47 pm 
Regular
Regular

Joined: Mon Oct 06, 2003 7:17 am
Posts: 58
Location: Switzerland
Does it work when you also update the register?

Reto


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 11, 2005 3:21 pm 
Newbie

Joined: Thu Apr 14, 2005 9:58 pm
Posts: 7
I have not tried that - since I do not have that scenario - once the user is registered, all the rest of the activities he performs are by logging in.

--Manju


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.