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 6769601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:12:45+00:00 2026-05-26T15:12:45+00:00

Consider the following Hibernate mappings: <hibernate-mapping package=org.example> <class name=Customer table=CUSTOMER> <id name=customerId column=customer_id/> <bag

  • 0

Consider the following Hibernate mappings:

<hibernate-mapping package="org.example">
  <class name="Customer" table="CUSTOMER">
    <id name="customerId" column="customer_id"/>

    <bag name="itineraries" table="ITINERARY" inverse="true" cascade="all">
      <key column="customer_id"/>
      <one-to-many class="Itinerary"/>
    </bag>

    <bag name="hotels" table="HOTEL" inverse="true" cascade="all">
      <key column="customer_id"/>
      <one-to-many class="Hotel"/>
    </bag>
  </class>
</hibernate-mapping>

<hibernate-mapping package="org.example">
    <class name="Itinerary" table="ITINERARY">
      <many-to-one name="customer" column="customer_id" update="false" not-null="true"/>
      ...other properties...
    </class>
</hibernate-mapping>

<hibernate-mapping package="org.example">
    <class name="Hotel" table="HOTEL">
      <many-to-one name="customer" column="customer_id" update="false" not-null="true"/>
      ...other properties...
    </class>
</hibernate-mapping>

Now say you need to remove the CUSTOMER table. How would you refactor the mappings/model such that the Customer Java object continues to contain Lists of Itinerary and Hotel objects based on a customerId? Said Hotel and Itinerary objects still need to be managed by Hibernate.

The best I can come up with is the Customer object deferring to DAOs when callers request a List. Is there a cleaner approach that will still allow the Customer object to live in each Itinerary and Hotel object?

  • 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-26T15:12:46+00:00Added an answer on May 26, 2026 at 3:12 pm

    Once you remove the customer table, the customer object will not be managed by Hibernate anymore. If you still want to have a customer object containing Itinerary and Hotel, then that needs to be done programmatically. I am not sure if you are really looking for this.

    One possible way of doing this is

    1. Lets say you have a DAO with a method getCustomer(). This accepts a customer id.
    2. This method fires two more queries to fetch lists of Itinerary and Hotel based on the customer id.
    3. It creates a Customer object and sets the lists of Itinerary and Hotel into it and returns it and populated customer object.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following Hibernate mapping file: <hibernate-mapping ...> <class name=ContentPackage table=contentPackages> <id name=Id column=id
Consider the following hibernate configuration: <class name=Person> <id name=id column=personId> <generator class=native/> </id> <set
Consider following example : public class SomeBusinessLayerService : DataService<MyEntityContainer> { [WebInvoke] void DoSomething(string someParam)
Consider following SWT code example: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java?view=co How can I separate the inline defined class?
Consider the following three Hibernate entities: public class Car { @OneToMany(fetch = FetchType.LAZY) @Fetch(FetchMode.SUBSELECT)
Consider following example: class CBase abstract { protected: CBase() { } }; I could
Consider following simple DAO example: public abstract class DAOFactory { public abstract AccountDAO getAccountDAO();
Consider following class class test { public: test(int x){ cout<< test \n; } };
Let's consider following, simplified example: We have 2 tabs withing <rich:tabPanel switchType=ajax> , each
I m not very versed in Hibernate and have following query: Consider two classes:

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.