-->
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: Foreign key in hibernate
PostPosted: Sat May 22, 2010 8:20 pm 
Newbie

Joined: Sat May 22, 2010 8:10 pm
Posts: 1
Hi All,

I am having two tables 1)project 2)Phase

Project table contains:
projectId
projectName
startDate
endDate

Phase table contains :
projectId as foregin key
phaseId as primary key
phaseName
startDate
endDate

this is one to many relation i.e one project can contain N phases. How do i mention foergin as projectID in Phase class?
Code:
<hibernate-mapping>
   <class table="project" name="com.vo.ProjectVO">
      <id name="projectId" column="projectId" >
      <generator class="increment"></generator>
      </id>
      <property name="projectName" column="projectName" />   
      <property name="startDate" column="startDate" type="date" />
      <property name="endDate" column="endDate" type="date" />
      
   </class>
   <class table="phase" name="com.vo.PhaseVO">
      <id name="phaseId" column="phaseId">
           <generator class="increment">
           </generator>
       </id>
      <property name="phaseName" column="phaseName"></property>
      <property name="startDate" column="startDate" type="date" />
      <property name="endDate" column="endDate" type="date" />
   </class>
</hibernate-mapping>


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.