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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:20:02+00:00 2026-05-10T21:20:02+00:00

Here are the domain model classes: public abstract class BaseClass { … } public

  • 0

Here are the domain model classes:

public abstract class BaseClass { ... }  public class ChildClass : BaseClass { ... } 

Note that the parent class is abstract and this is what gives me some difficulties when comes the time to map with fluent nhibernate. My discriminator is a byte (tinyint in the DB). Because it is not a string and I can’t manage to set a discriminator value on the base class, this does not work (taken from the mapping class for BaseClass):

DiscriminateSubClassesOnColumn<byte>('Type')     .SubClass<ChildClass>()     .IsIdentifiedBy((byte)OperationType.Plan)     .MapSubClassColumns(p => { ... }) 

The error message I get is:

Class Initialization method UnitTest1.MyClassInitialize threw exception. NHibernate.MappingException: NHibernate.MappingException: Could not format discriminator value to SQL string of entity BaseClass —> System.FormatException: Input string was not in a correct format..

The following post seems to explain what happens. They give a solution with xml but not with fluent nhibernate: http://forum.hibernate.org/viewtopic.php?t=974225

Thanks for the help.

  • 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. 2026-05-10T21:20:02+00:00Added an answer on May 10, 2026 at 9:20 pm

    I have found a workaround but this seems so like a patch… I added the following to the mapping file:

    SetAttribute('discriminator-value', '-1'); 

    It seems to instruct FNH not to use a string (I think it uses the class name) for the abstract base class. To make it work with the -1 value, I also changed my discriminator type from byte to sbyte.

    Edit: I missed that: this is the second parameter to DiscriminateSubClassesOnColumn that takes the default value. So the correct answer to my question is:

    DiscriminateSubClassesOnColumn<sbyte>('Type', (sbyte)-1) 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 68k
  • Answers 68k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Maybe something like this: $curRow[1]/@*[ name() = $curCol/@id ] May 11, 2026 at 12:09 pm
  • added an answer Use the Referer header from the HTTP Request. In PHP… May 11, 2026 at 12:09 pm
  • added an answer The name of the command line C++ compiler is cl.exe… May 11, 2026 at 12:09 pm

Related Questions

Here are the domain model classes: public abstract class BaseClass { ... } public
Here are the declarations of the variables: string strFirstName; string strLastName; string strAddress; string
Here are the requirements: Must be alphanumeric, 8-10 characters so that it is user
Here are the points that seem vague to me : High-Fan in : have
Here are the specs that I'm trying to implement in a nutshell: 1) Some
Here are the errors: $ perl ftper.pl Use of uninitialized value $id in hash
edit: many thanks for all the answers. Here are the results after applying the
What order of precedence are events handled in JavaScript? Here are the events in
I have a Rails app that I need to deploy. Here are the facts:
Here are a few possibilities to get the conversation started: Escape all input upon

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.