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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:46:02+00:00 2026-05-28T04:46:02+00:00

Info: There is a group object. Users can be invited to groups. There are

  • 0

Info:
There is a group object. Users can be invited to groups. There are two types of group invitations: external and internal. All invites are stored in single table using discriminator. The group object knows only about internal invites.

Problem In the Invite table there are two records. One for internal and one for external. If I load the group I will see both invites even the collection is of type InternalInvite. InternalInvite result.

SELECT internalin0_.Group_id as Group3_1_,
   internalin0_.Id       as Id1_,
   internalin0_.Id       as Id0_0_,
   internalin0_.Group_id as Group3_0_0_,
   internalin0_.User_id  as User5_0_0_

FROM [AbstractInvite] internalin0_
WHERE internalin0_.Group_id = ‘be60b160-659e-4157-b033-9f9e00e346c7’

When I change the ISet collection type to AbstractInvite it will load all invites with the correct type.

Question How can I map the collection property to only InternalInvites?

I will try to minimize the code as much as I can.

The group and the group mapping:

public class Group
{
    public Group()
    {
        InternalInvitations = new HashedSet<InternalInvite>();
    }
    public virtual Guid Id { get; set; }
    public virtual ISet<InternalInvite> InternalInvitations { get; set; }
}

public class GroupMap : ClassMap<Group>
{
    public GroupMap()
    {
        Id(x => x.Id);
        HasMany(x => x.InternalInvitations).Inverse();
    }
}

The external and internal invite + mappings:

public abstract class AbstractInvite
{
    public virtual Guid Id { get; set; }
    public virtual Group Group { get; set; }
}

public class ExternalInvite : AbstractInvite
{
    public virtual string Name { get; set; }     
}

public class InternalInvite : AbstractInvite
{
    public virtual User User { get; set; }
}

public class AbstractInviteMap : ClassMap<AbstractInvite>
{
    public AbstractInviteMap()
    {
        Id(x => x.Id);
        References(x => x.Group);
        DiscriminateSubClassesOnColumn("type");
    }
}

public class ExternalInviteMap : SubclassMap<ExternalInvite>
{
    public ExternalInviteMap()
    {
        Map(x => x.Name);
    }
}

public class InternalInviteMap : SubclassMap<InternalInvite>
{
    public InternalInviteMap()
    {
        References(x => x.User);
    }
}
  • 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-28T04:46:03+00:00Added an answer on May 28, 2026 at 4:46 am

    I will answer to myself.

    I was able to achieve my goal with the code below:

    public class AbstractInviteMap : ClassMap<AbstractInvite>
    {
        public AbstractInviteMap()
        {
            Id(x => x.Id);
            References(x => x.Group);
            DiscriminateSubClassesOnColumn("type").AlwaysSelectWithValue();
        }
    }
    

    Reference: Discriminator in NHibernate documentation. Focus on ‘force’ option.

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

Sidebar

Related Questions

There are two tables. One is users info users, one is comments info comments.
Originally there was the DAL object which my BO's called for info and then
I find useful groups.google.com/group/comp.lang.prolog/topics cs.cmu.edu/afs/cs/project/ai-repository/ai/areas/ google.com/Top/Computers/Programming/Languages/Prolog/Implementations/ allisons.org/ll/Logic/Prolog/Examples/ prolog.info/ Maybe there are else useful links?
Any info out there on how to print the generated charts in say PDF
I haven't browsed through the spec, though I doubt any info is in there.
There doesn't seem to be much info on this topic so I'm going to
Is there any method / API defined to collect system info in osx. I
Is there a way to get the session info from a remote windows server
Is there a way to hide date and user info from a page post
Is there a cucumber command that will print out just the feature info and

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.