Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7196223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:44:12+00:00 2026-05-28T20:44:12+00:00

There are database tables in mysql at the backend corresponding to these classes with

  • 0

There are database tables in mysql at the backend corresponding to these classes with Foreign Keys defined accordingly. Let me know if I need to put those relations here.

class Itinerary {
 Airport Departure;
 Airport Arrival;
 Airline flight;
}

class Airport{
 int idAirport;
 String terminal;
 City city;
}

class City{
 int idCity;
 String name;
}    

class Airline{
 int idAirline;
 String flightNumber;
}

I use something like this: http://pastebin.com/YzYMTBg3 to build an itinerary object. This is what is puzzling me, and I don’t know what is a good way to handle this using hibernate as my ORM.


AirSegmentBuilder segmentBuilder = new AirSegmentBuilder();
segmentBuilder.addDepartureAirport("JFK");
segmentBuilder.addArrivalAirport("SFO");

I am trying to add departure and arrival airport (objects) to my itinerary here. These objects in turn persist in database as:

Airport:

id    |    name    | terminal
1     |    JFK     |  1
2     |    SFO     |  B1

So when I need to add these airports to my itinerary, do I need to fetch the airport objects first using a query based on name?; and then attach these objects to itinerary? Once I have the itinerary object built and save it to the database using hibernate, would it be able to pick up the foreign keys correctly ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:44:13+00:00Added an answer on May 28, 2026 at 8:44 pm

    Assuming you are using xml to configure your hibernate stuff.
    You may write your Itinerary.hbm.xml like this to achieve your goal :

    <many-to-one name="Airport" class="pkg.Airport"
                    column="foregn_key1" not-null="true" fetch="join" />
    <many-to-one name="Airline" class="pkg.Airline"
                    column="foregn_key2" not-null="true" fetch="join" />
    

    where Airport, Airline and Itinerary are the tables in your DB.
    Hope this helps…

    Note – This is just a kind of example. You may need to update your beans accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySql database with three tables I need to combine in a
I need a simple app to edit database tables. Are there any code generators
I know you can print all the tables in MySQL database using show tables;
In a MySQL (5.1) database table there is data that represents: how long a
Is there any application that will read a MySQL database table and generate a
The table names in my mysql database are dynamically generated. Is there some way
in my database there are 3 tables CustomerType CusID EventType EventTypeID CustomerEventType CusID EventTypeID
I have an existing database with tables which each have 4 partitions (there are
I've got collection of geo objects in database: There are four Tables: Countries Regions
Hi is there a free avaible translation backend with database avaible which can handle

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.