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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:51:36+00:00 2026-06-03T23:51:36+00:00

In my application I am trying to implement Hibernate mappings through annotation. There I

  • 0

In my application I am trying to implement Hibernate mappings through annotation. There I have a base class which is abstract, in this class the Id attribute is present. I am inheriting this base class with a child class. The code is given below:

@MappedSuperclass
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class Base implements IBase {

    private static final long serialVersionUID = -1433573674276444516L;

    private int id;

    public Base() {

    }

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)   
    @Column(name="ID")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
}

And the child class is:

@Entity
@Table(name="USER")
public class User extends Base implements IUser {

    private static final long serialVersionUID = 344528694909088439L;

    private String name;

    public User() {

    }

    @Column(name="NAME", nullable=false)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }   
}

It is creating the USER Table and working fine.

I was wondering whether or not I am doing it in right way.

Thanks.

  • 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-03T23:51:38+00:00Added an answer on June 3, 2026 at 11:51 pm

    If the goal is just to have several independant entities to inherit a common field from a base class, then no, you’re not doing it correctly. The annotation @Inheritance is unnecessary. @Inheritance is necessary when you have an entity (Vehicle, for example), and several sub-entities (Car, Bike, for example).

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

Sidebar

Related Questions

I have an application in which I am trying to implement ManyToMany relation between
I am trying to implement the blackberry application which will help the user to
I'm trying to implement this pattern in my WinForms application (I don't like it,
I'm developing an asp.net (classic) application trying to implement the MVP pattern using this
I am trying to implement an application by using MySQL/JAVA and I found this
I am trying to implement a selection wheel in an iphone application. I have
i am trying to implement the functionality of email in my application. i have
I'm trying to implement a Hibernate persistence layer in a Java application and I'm
I have an ASP.NET webforms application and trying to implement jQuery autocomplate on a
I'm trying to add some Hibernate functionality to a Spring web application. This is

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.