Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Foreign key in hibernate

 
sarada srinivas
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 foreign key as projectID in Phase class and i don't want to use set,array as one to many?

 
Rendi Artha
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just define many to one relationship into Phase.hbm.xml

 
sarada srinivas
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much ....

It was resolved....

Phase.hbm.xml

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic