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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:54:59+00:00 2026-06-03T21:54:59+00:00

I have a Bean class called Bean_A that is map to table_A, and this

  • 0

I have a Bean class called Bean_A that is map to table_A, and this Bean_A class is inherited from a base bean class, and the base bean class will have a unique_reference_key variable that will going to save into the database together with the Bean_A class. I already have the hibernate file ready for the Bean_A and the unique_reference_key field in table_A.

May I know how could I map the base bean class in hibernate to ensure this unique_reference_key variable is save into database when I was saving the Bean_A object? Take note that this base bean class is not map to any table in database, and there is no such table that “represent” the base bean.

Before I throw out this question, I have consult the following article but still couldn’t get any clue on it.

  1. Hibernate simplifies inheritance mapping
  2. Hibernate Chapter 5.Basic O/R Mapping
  • 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-03T21:55:00+00:00Added an answer on June 3, 2026 at 9:55 pm

    I have found the solution on how to map the base bean property into Bean_A in hibernate.

    In hibernate:

    <class name="com.dao.pojo.BaseBean" abstract="true">
       <id name="theId" type="string">
          <column name="primary_key" length="15" />
       </id>
       <property name="unique_ref_key" type="java.lang.String" column="unique_ref_key"/>
    
       <union-subclass name="com.dao.pojo.Bean_A" table="table_A" lazy="false">
          ...
       </union-subclass>
    </class>
    

    Please note that theId was originally from Bean_A and it has been move to BaseBean. A new field, unique_ref_key, is created inside table_A.

    In JAVA:

    public abstract class BaseBean {
       private String theId;
       private String unique_ref_key;
    
       // getter and setter
    }
    
    public class Bean_A extends BeseBean {
       ...
    }
    

    Hope this solution can help others.

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

Sidebar

Related Questions

i have an managed bean(session scope) like this: class Home {// as homeBean public
I have this Spring config: <bean id=boo class=com.x.TheClass/> The class TheClass implements TheInterface .
I have a simple class that has a property called executor in which I'd
I have a managed bean called: @ManagedBean(name=configBean) @SessionScoped public class configBean implements Serializable {
The schema: (psuedocode) I have a bean, called BaseEntity... @Entity class BaseEntity { @OneToMany
I have a bean with a field called 'name', and a JSF form that
I have a boolean field called showLabels in a Bean class, and I want
I have this Person class that is part of various other transactions like a
Say I have the following simple java bean: class MyBean { private Date startDate;
I have a class which would create a bean and the bean has few

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.