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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:56:04+00:00 2026-06-01T04:56:04+00:00

Consider a Transport table with 3 fields: Engine Wheels Wings If Engine and Wheels

  • 0

Consider a Transport table with 3 fields: Engine Wheels Wings

If Engine and Wheels are non-null and Wings is null then I wish to map this to a Vehicle class
If Engine and Wings are non-null and Wheels is null then I wish to map this to a Plane class

I have been reading about discriminators to differentiate between subclasses but in any of the examples that I’ve read, they always refer to a discriminator value. Therefore, I’m wondering how I can go about my above scenario?
Do I just implement separate mappings? I was hoping to find a neater way.

Thanks

Edit

Have just looked through the reference guide again and have noticed that null and not-null are valid values. So looks like this solves my problem. Will leave this open for a little while to confirm. 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-01T04:56:05+00:00Added an answer on June 1, 2026 at 4:56 am

    You can create an abstract parent class for your Plane and Vehicle classes and use @DiscriminatorFormula, which you use to write a formula that generates a value that you can later annotate as the @DiscriminatorValue for the Plane and Vehicle subclasses.

    Take a look at this example in the Hibernate docs (though this example uses XML for the mapping, it’s basically the same thing for the annotation):

    http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/example-mappings.html#example-mappings-content-discrimination

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

Sidebar

Related Questions

Consider the following jsf page: <h:body> <h:form id=SessionStartDialog> <table> <tr> <td class=label> <h:outputLabel value=Enter
Consider this problem: I have a program which should fetch (let's say) 100 records
Consider the Oracle emp table. I'd like to get the employees with the top
Consider an indexed MySQL table with 7 columns, being constantly queried and written to.
Consider these classes. class Base { ... }; class Derived : public Base {
Let's consider this sample example text file: Level: 1 Level: 1 Level: 2 Level:
Consider, please this setup for a database backed application. ( in my case DB
Consider the following file transport application, which uses the protocol defined below to reliably
Trying to build what I believe to be a contingency table, please consider the
please consider this reproducible example: from PIL import Image import numpy as np import

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.