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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:28:01+00:00 2026-05-26T11:28:01+00:00

In the most simplified version , here is my problem public class D{ public

  • 0

In the most simplified version , here is my problem
enter image description here

public class D{
 public List<A> ListofA {get;set;}
}

public interface A{
}

public class B implements A{
}

public class C implements A{
}

class B maps to Table B
class C maps to Table C

A is just an interface and is not mapped to any table.

How do I define the polymorphic (many-to-many) association between D -> A

I am using NHibernate with FluentMapping.

  • 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-26T11:28:02+00:00Added an answer on May 26, 2026 at 11:28 am

    I am attemped to answer my own question.
    However I would like to find out BETTER/ MORE RATIONAL solution to this problem.

    Here is my solution:

    Redesign Class D

    I redesign class D as

          public class D {
                  public List<MagicObj> ListofA {get;set;}
          }
    
           //New Entity added which was not there in the question before.
           public class MagicObj{
                  public A   ActualEntity{get;set;}
           }
    

    NO changes in the remaining entities.

             public interface A{
    
             }
    
             public class B implements A{
    
             }
    
             public class C implements A{
    
             }
    

    This design change should allow me to map

    Fluent Mapping

    for the above redesigned class structure

    D->MagicObj as HasMany(x=>x.ListofA)
    MagicObj->A as ReferenceAny(x=>x.ActualEntity)
                        .EntityIdentifierColumn("EntityType")
                        .EntityIdentifierColumn("EntityId");
    

    Guess I choose to use add a new relation between Class D and Class A is that
    I was not able to find a way to map it directly in Fluent.

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

Sidebar

Related Questions

This is the most simplified version of my view. public class MyView extends View
I have a DataTables table. Here's a simplified version of what I have as
Here is a simplified version of my table tbl_records -title -created -views I am
I have the following C++ code (simplified version): class Shape { bool isCircle =
The following example is a very simplified version of my top navigation. http://jsfiddle.net/AEqxT/ If
Given a (simplified) table CREATE TABLE `transactions` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `CREATION_DT`
I'm looping through JSONP with JQuery in order to get a list of usernames.
Looking at the following (simplified) hierarchy of classes: > Email (base class) > SimpleEmail
Most of my C/C++ development involves monolithic module files and absolutely no classes whatsoever,
Most of time we represent concepts which can never be less than 0. For

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.