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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:37:02+00:00 2026-05-16T11:37:02+00:00

i have a parent entity Service and a child ExtendedService in a SINGLE_TABLE inheritance.

  • 0

i have a parent entity Service and a child ExtendedService in a SINGLE_TABLE inheritance.

A third entity ServiceCollector need to include both entites Service and ExtendedService. This is a fixed requirement, and with this design i can realize it using polymorphism.

THE PROBLEM: Very often i need to retrieve ONLY the parent class Service, so i query it by discriminator column… i think this is a bad design for my purpouse, isn’t true?

This is a simple example, indeed i have a lot of Service subclasses, think for example to a shop that sell different product, each product can have a different properties.

Thanks in advance.

  • 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-16T11:37:03+00:00Added an answer on May 16, 2026 at 11:37 am

    If every ExtendedService isn’t valid as a response to a query for Service, sounds more like you have Templating through Inheritance, rather than Polymorphism. A simple fix is to make Service abstract, so you have AbstractService and an empty class Service that extends it and just defines the DiscriminatorValue. (Then ExtendedService extends AbstractService, etc.)

    Mapping the discriminator column to query it isn’t exactly the end of the world, if everything else is working fine for you. Personally I’d file it more towards “Inelegant” than “Bad Design” but that’s just opinion.

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

Sidebar

Related Questions

I have a parent entity in my model Event. And two child entities: Birthday,
I have a Parent entity with 2 child entities ( Foo and Bar )
I have a parent-child relationship: @Entity @Table(name = user) public final class User {
I use Entity Framework 4 and I have parent - child relation with Cascade
I have two entities types: RunContainer parent entity type Run child entity type Run
I have a parent entity (Treatment) with a collection of child entities (Segments). I
I am using Entity Framework CodeFirst where I have used Parent Child relations using
consider this scenario: I have loaded a Parent entity through hibernate Parent contains a
I have one parent child entity : public class Transaction { public int TransactionId
I have a parent child relationship between 2 classes Parent @Entity @Table(name = PARENT)

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.