-->
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.  [ 3 posts ] 
Author Message
 Post subject: Primary Key Foreign Key Association(Foreign Key null)
PostPosted: Thu Nov 22, 2007 3:46 am 
Newbie

Joined: Thu Nov 22, 2007 3:28 am
Posts: 3
Hi,

I am developing a workflow management system using jboss-jbpm. I am using mysql as database,
and using hibernate for OR mapping.

Problem: I got a parent table(Name:User_Table) and a child table(Name:Member_Table)
There is a primary key foreign key association with User_Table and Member_Table.
The primary key field in User_Table is an autoincriment field.
Two Value Objects(VO) are there for each Tables.
when i save the datas into the User_Table one row is also inserted in the
Member_Table,but the foreign key column is null.

My *.hbm.xml files are given below


1)Membership.hbm.xml
<class name="MembershipVO" table="Member_Table">
<id name="id" type="int" column="ID_" />
<property name="name" type="string" column="NAME_" />
<property name="role" type="string" column="ROLE_" />
<property name="group" type="int" column="GROUP_" />
<property name="memberClass" type="string" column="CLASS_" />
<many-to-one name="userVO" class="UserVO" column="USER_"></many-to-one>
</class>

2)User.hbm.xml

<class name="UserVO" table="User_Table">
<id name="id" type="int" column="ID_" >
<generator class="native"></generator>
</id>
<property name="userName" type="string" column="NAME_" />
<property name="password" type="string" column="PASSWORD_" />
<property name="email" type="string" column="EMAIL_" />
<property name="userClass" type="string" column="CLASS_" />
</class>



Thanks in advance
Dejies


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 22, 2007 11:07 pm 
Newbie

Joined: Fri Mar 30, 2007 5:23 pm
Posts: 16
Location: New York, NY
Can you post some sample code which creates and persists the objects? Nothing jumps out in the mapping as a possible cause (though I would suggest putting a <generator/> node in the id field for the Membership class.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 1:39 am 
Newbie

Joined: Thu Nov 22, 2007 3:28 am
Posts: 3
Dear Matbrown .

Thanks for the reply.
I added the generator class and now my code is working fine.

Regards
Dejies Deoder


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