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

  • Home
  • SEARCH
  • 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 1069609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:26:36+00:00 2026-05-16T20:26:36+00:00

I have a problem with a mapping for this structure that i designed public

  • 0

I have a problem with a mapping for this structure that i designed

public abstract class A<T> {
 private int discriminator_value = -1;
 private T value;
 //...
}

public class One extends A<String> {

 public One(){
  setDiscriminatorValue(1);
 }
 //...
}

public class Two extends A<BigDecimal> {

 public Two(){
  setDiscriminatorValue(2);
 }
 //...
}

public class Three extends A<Date> {

 public Three(){
  setDiscriminatorValue(3);
 }
 //...
}


public class TheTargetSolution {
  private Long info1;
  private Long info2;
  private Long info3;
  private A targetPojo; 
 //...  
}

The table structure

 THE_TARGET_SOLUTION_TABLE
  - INFO_1   NUMBER(10)
  - INFO_2   NUMBER(10)
  - INFO_3   NUMBER(10)
  - DISCRIM  NUMBER(2)
  - TEXT_A   NVARCHAR2(200 BYTE)
  - NUMBER_A NUMBER(10)
  - DATE_A   DATE

The main thing is that we need to have in TheTargetSolution the targetPojo that is type of A class and this class does not have mapping, (we need more info to entity and thees is no option to do this using relation many to many in this case all data has to be stored in one table) that is instance of type that apply to discriminator.

Resuming

When the DISCRIM column value is 1 the targetPojo should by type of One

When the DISCRIM column value is 2 the targetPojo should by type of Two

When the DISCRIM column value is 3 the targetPojo should by type of Three

Any suggestions ?

  • 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-16T20:26:36+00:00Added an answer on May 16, 2026 at 8:26 pm

    This is typical scenario for inheritance, with table-per-class-hierarchy. If you use xml, see the linked docs. If using annotations, use

    @MappedSuperclass
    @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
    @DiscriminatorColumn(name="DISCRIM", discriminatorType=INTEGER)
    public abstract class A {
       // properties here
    }
    

    And then

    @Entity
    @DiscriminatorValue("1")
    public class Two extends A<BigDecimal>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data structure that stores amongst others a 24-bit wide value. I
I have the following classes (trimmed to only show the basic structure): public abstract
This is my problem set for one of my CS class and I am
I have a problem creating a mapping for a json that i want to
I have a problem with the mapping of Oracle Float double precision datatype to
I have a problem with nhibernate mapping. I use the nhibernate 3.2 mapping by
I have a problem which requires a reversable 1:1 mapping of keys to values.
I have problem with my query on C, I’m using the oci8 driver. This
This may be an incredibly stupid question, but I have a web application that
I have a problem mapping an Id. The structures of the entities are as

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.