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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:15:49+00:00 2026-05-25T06:15:49+00:00

First of all, please forgive my ignorance in both Java and Hibernate, I’m studying

  • 0

First of all, please forgive my ignorance in both Java and Hibernate, I’m studying different ORM solutions and am not a Java programmer.

1) Is it possible to map the following class hierarchy to a database table, with Person.name and Employee.name pointing to different columns?

abstract public class Person {
        private String name;
}

public class Employee extends Person {
        private String name;
}

2) Supposing that the answer to 1) is Yes, is there a way to create a HQL or Criteria query which would ask Hibernate to return Employee objects, with a criterion on Person.name?

Something like that:

SELECT e FROM Employee e WHERE e.super.name = "test";
  • 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-25T06:15:49+00:00Added an answer on May 25, 2026 at 6:15 am

    1) Yes. This can be accomplished via a MappedSuperclass, and annotating your columns

    @MappedSuperclass
    abstract public class Person { 
      @Column(name="PERSON_NAME")
      private String name; 
    }
    @Entity
    public class Employee extends Person {
            @Column(name="EMPLOYEE_NAME")
            private String name;
    }
    

    2) No. Not without changing the attribute names of one of either Person or Employee. You could however query for all person objects with that name and cast the results to Employees. Another option would be to use Native SQL to query the column you want, again probably not ideal.

    SELECT p FROM Person p WHERE p.name = "test";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all I am a programmer (Python, C, Java, Delphi, whatever) and not
First of all, please forgive me for not knowing the proper terminology, I'm sure
First off, I am not an AS 400 guy - at all. So please
I'm not a Rails developer (currently) so please forgive my ignorance on this. One
First off, I am not a Unix expert by any stretch, so please forgive
First of all, please forgive me for my vocabulary is a little limited with
First of all please forgive me if its a really dumb question, I am
I was involved in couple of cloud computing platform recently. First of all please
First of all, sorry for my ignorance of the window creation process. Today is
First of all, I know how to build a Java application. But I have

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.