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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:53:50+00:00 2026-06-04T16:53:50+00:00

I have a set of payment objects that come from different sources that I’d

  • 0

I have a set of payment objects that come from different sources that I’d like to use an TPC inheritance in NHibernate for. The base for all these object is the payment processor (so all have a consistent format), however there is no representation of the base class in the database. I think I have my mapping worked out, except for the fact that I get an exception thrown when trying to insert – “Cannot use identity column key generation with <union-subclass> mapping for: <EntityName>”

Classes:

public class BasePayment
{
    public virtual int Id { get; set; }
    public virtual PaymentSource Source { get; set; }
    public virtual DateTime Date { get; set; }
    public virtual decimal Amount { get; set; }
}

public class SubPayment : BasePayment
{
}

Mappings:

public class BasePaymentMap : ClassMap<BasePayment>
{
    public BasePaymentMap()
    {
        UseUnionSubclassForInheritanceMapping();
        DiscriminateSubClassesOnColumn("Source");
        Id(m => m.Id);
        Map(m => m.Source);
        Map(m => m.Amount);
        Map(m => m.Date);
    }
}

public class SubPaymentMap : SubclassMap<SubPayment>
{
    public SubPaymentMap()
    {
        DiscriminatorValue(PaymentSource.SourceX);
        Abstract();
        Table("SourceXPayments");
    }
}

And that’s as far as I’ve got. On a SaveOrUpdate, I’m getting the error above, and a google search is not proving helpful thus far – I have found this question: Cannot use identity column key generation with <union-subclass> ( TABLE_PER_CLASS ) which appears to cover the issue in Java/Hibernate, but I’m having a problem with converting the @GeneratedValue(strategy = GenerationType.TABLE) into a Fluent syntax, as Fluent NHibernate’s GeneratedBy() method doesn’t seem to have a table, or a lot of documentation (that I have found) as to what it does under the covers.

Doing some more reading around it seems that this might not be possible, so if anyone can confirm this or offer a work around for the situation, it’d be greatly appreciated.

If I’ve not given enough detail, please let me know what would be more use.

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-06-04T16:53:52+00:00Added an answer on June 4, 2026 at 4:53 pm
    UseUnionSubclassForInheritanceMapping();
    DiscriminateSubClassesOnColumn("Source");
    

    is conflicting and FNH will ignore one.

    UseUnionSubclassForInheritanceMapping means each class has it’s own table with all columns and the table is used to discriminate the class, no column needed

    DiscriminateSubClassesOnColumn means each class of the inheritance hierarchy live in the same table and a column is used to discriminate the classes.

    the error message means that when using UseUnionSubclassForInheritanceMapping identity generation is not allowed since the id’s would be unique for one table only but NHibernate threats all subclasses as one set where the id must be unique.

    e.g. session.Get<BaseClass>(5); won’t work relyably anymore since there could be more than one subclass with the same id.

    @GeneratedValue(strategy = GenerationType.TABLE) just tells “use another strategy than identity”. GeneratedBy.HiLow(); would be a good alternative to identity.

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

Sidebar

Related Questions

I have set up 2 servers which are linked. From my LOCAL SERVER, I
I have set up a Core Data model where I have two objects, say
We have set up Website Payments Pro account and I managed to use ruby
I have this result set from my query: OrderId CustomerId ProducerId CustomerPayment ProducerPayment 1
I have an asp.net mvc e-commerce application that requires voucher payment. how to pass
In a current project, I have a model called Box that stores items from
I am trying to display information from database. I have set $config['per_page'] to 2,
I am trying to get the fastspring subscription payment processing set up. I have
I have a UITableView set up with different in app purchases. Each option takes
Description I have a payment page that includes a form for entering bank account

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.