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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:08:46+00:00 2026-05-13T00:08:46+00:00

I have to map a lecagy database for read-only purposes that contains the following

  • 0

I have to map a lecagy database for read-only purposes that contains the following structure:

Table MAIN: 
id productId productType

Table PRODUCT_A: 
id description_a

Table PRODUCT_B: 
id description_b

Table PRODUCT_C: 
id description_c

Depending on the value in column productTyp, the productId refers either to the PRODUCT_A,PRODUCT_B, or PRODUCT_C.

For each of the tables I create a Java entity. The Main class contains one collection for each product.

The products are not in a ‘is a’ relationship with the main class. It is used under other circumstance as independent entity.

Is there any way to map this using hbm.xml files?

  • 1 1 Answer
  • 1 View
  • 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-13T00:08:46+00:00Added an answer on May 13, 2026 at 12:08 am

    The proper way to map this is via <any>:

    <class name="Main" table="MAIN">
      ...
      <any name="product" id-type="long" meta-type="string">
        <meta-value value="PRODUCT_A" class="ProductA"/>
        <meta-value value="PRODUCT_B" class="ProductB"/>
        <meta-value value="PRODUCT_C" class="ProductC"/>
        <column name="productType"/>
        <column name="productId"/>
      </any>
    </class>
    

    You’ll have to map the appropriate ProductA etc… classes to corresponding tables (perhaps you already have).

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

Sidebar

Related Questions

In my Map application I have segment controller on main screen and using that
I have a map that represents a DB object. I want to get 'well
I have a Map that uses a Set for the key type, like this:
I have a Map, that I want to persist. The domain object is something
I have Java Map (out of Strings and Ints) objects that I want to
for example we have map map<char,int>mymap; mymap['a']=101; mymap['c']=45; mymap['b']=76; mymap['d']=98; i know that if
I have a map that is cut up into a number of regions by
I have map application in which I have a button. On clicking that button
I have map control on main form. Problem is, when form designer generate code
I have a map that stores pointers to an object by their ID. typedef

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.