This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate and class association Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate and class association" Watch "Hibernate and class association" New topic
Author

Hibernate and class association

ben oliver
Ranch Hand

Joined: Mar 28, 2006
Posts: 375
My current Traveling agent application system includes lot of class associations like

class Tour {
Flight f;
int i;
double d;
....
}

class Flight {
Log l;
int i;
double d;
....
}

class Log {
Date departure ;
Date arrival ;
....
}
The application and database start from scratch.
1. can we use hibernate to handle such complex chained object relation ? Can we easily get "Tour" information and grab all of the "Flight" and "Log" information associated with the "Tour" ?
2. should the tables be created in the same or different format from the above class struture ? which will be better ?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


1. can we use hibernate to handle such complex chained object relation ? Can we easily get "Tour" information and grab all of the "Flight" and "Log" information associated with the "Tour" ?

Yes.


2. should the tables be created in the same or different format from the above class struture ? which will be better ?

There is not really enough information here to say conclusively (Must tours have a Flight? Can they have more than one Flight? Can a Log exist independent of a Flight? etc.) but assuming the association is one to many for Tour to Flight and Flight to Log then it looks OK.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hibernate and class association