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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:56:42+00:00 2026-06-02T11:56:42+00:00

Is it possible to get a table per concrete mapping in nhibernate/fluent to issue

  • 0

Is it possible to get a table per concrete mapping in nhibernate/fluent to issue a database statement to determine the type of class and then issue another statement for the detail rather than joining all the subclass tables in a massive left joined uber-statement.

In other words can the sub class detail be ‘lazy’ loaded.

I have a class heirarchy mapped using fluent nhibernate and ClassMap/SubClassMap mapping classes. Each derived class (most of them anyway) have their own table. So it’s a table per concrete class.

I have not specified discriminator values because they are used when all the sub classes are contained in the same table. I do however have an integer value in the base class table that indicates which type it is. Is nhibernate capable of using this data and issuing a lazy load for the derived class data. The discriminator value is an integer in the database that corresponds to an enum in the base class.

example.

public sealed class PartyMap : ClassMap<Party>
{
  public PartyMap()
  {
     Table("Party");
     // I thought this might do it, but it doesn't :-(
     Polymorphism.Explicit();
     Id(x => x.Id).Column("PartyId");
     Map(x => x.PartyType).CustomType<PartyType>().Column("PartyTypeId");
     Map( ...
     // if I specify this, nhibernate expects all the fields
     // to be in the base class table, above Table(...) is the only one used.
     // DiscriminateSubClassesOnColumn<int>("PartyTypeId", 0).AlwaysSelectWithValue();
   }
}

public class PersonMap : SubclassMap<Person>
{
    public PersonMap()
    {
        Table("Person");
        KeyColumn("PartyId");   
        // if I specify this, nhibernate expects all the fields
        // to be in the base class table, above Table(...) is ignored.      
        // DiscriminatorValue((int) PartyType.Person);
     }
}
  • 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-02T11:56:45+00:00Added an answer on June 2, 2026 at 11:56 am

    Short answer: no, it is not possible. IIRC, the behavior is exactly the same even if you use a discriminator.

    If too many joins are a concern (because you have lots of inheriting classes) you should consider using Table per class hierarchy, or Table per sublass with discriminator (if most classes have a similar set of properties, with only a few of them being totally different)

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

Sidebar

Related Questions

Is it possible to somehow get structure of MySQL database, or just some table
Using table per type inheritance is it possible to have the same data with
Possible Duplicate: Printing Table's structure/schema oracle has 'DESCRIBE' to get all the details of
In a Table-Per-Hierachy scenario is it possible to discriminate on a list of possible
I'm using table per hiearchy for the following model: Story (base class) - Individual
I'm using EF4.1 with Code first and TPT (Table per Type) inheritance. I have
Possible Duplicate: mysql: Using LIMIT within GROUP BY to get N results per group?
Possible Duplicate: SQL: Find the max record per group I have a table with
does anyone know how to (if possible) get the owner of the tag on
I am trying to work out if it is possible get JPA to persist

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.