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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:40:49+00:00 2026-06-04T07:40:49+00:00

I am in the process of learning Hinbernate, so a thought passed if I

  • 0

I am in the process of learning Hinbernate, so a thought passed if I could map two classes to one DB table.

Ex :

Class Developer {
    String name;
}

Class Manager {
    String name;
}

Whereas both these classes are mapped to one table, lets say by name Employee with one column of String datatype.

Will Hibernate be able to create rows in table based on the class I am using for creating.
Or do you think there should be a discriminator column to differentiate between classes?

NOTE : There are no inheritance relationships between the classes, they are separate.

  • 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-06-04T07:40:51+00:00Added an answer on June 4, 2026 at 7:40 am

    When you use xml mapping files, you simply can create two mapping files Developer.hbm.xml and Manager.hbm.xml, which both refer to the same database table. That works.

    The problem is, you must ensure a table row only is loaded as a Developer or a Manager, but not as both. If for example you load them with session.createQuery("from Developer") and session.createQuery("from Manager"), then you have the same row two times in the session cache. If you then first modify and update Developer, after that you modify and update the same row in Manager, then the modification in Developer is lost, and the session cache is inconsistent.

    Thus, a discriminator row is not absolutely necessary but highly recommended.

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

Sidebar

Related Questions

On the process of learning Assembly i got one question If i do the
I'm in the process of learning WPF, where one of the strong suits is
I am in the process of learning Backbone.js. I currently assume that if one
I'm in the process of learning iOS development and have two simple and related
Im the process of learning C++. I got stuck debugging some of my code
I'm in the process of learning Databases and SQL. From what I have read
I am in the process of learning about big oh notation. For the code
I'm in the process of learning jQuery and the tutorial I'm following uses Dreamweaver
I am in the process of learning how to use SWIG on Windows. The
I am in the process of learning C++ and came across an article on

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.