File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Foreign key in hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "Foreign key in hibernate" Watch "Foreign key in hibernate" New topic
Author

Foreign key in hibernate

sarada srinivas
Greenhorn

Joined: Oct 09, 2008
Posts: 20
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

Joined: Jan 20, 2010
Posts: 29
just define many to one relationship into Phase.hbm.xml

sarada srinivas
Greenhorn

Joined: Oct 09, 2008
Posts: 20
Thank you very much ....

It was resolved....

Phase.hbm.xml

 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Foreign key in hibernate
 
Similar Threads
Convert SQL to HQL
many-to-many where middle table has extra fields
Problem with Hibernate composite key mapping
Not-null property references a null or transient value
Validating Hibernate mapping file with -set- and -join- elements