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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:00:27+00:00 2026-05-22T22:00:27+00:00

I am using nhibernate to map the following classes: public class DeviceConfig : EntityBase

  • 0

I am using nhibernate to map the following classes:

public class DeviceConfig : EntityBase
{
    public virtual string Name
    {
        get { return m_Name; }
        set { SetValue(ref m_Name, value); }
    }
    public virtual string Description
    {
        get { return m_Description; }
        set { SetValue(ref m_Description, EmptyStringIfValueNull(value)); }
    }
}

 public class DeviceConfigEmail : DeviceConfig 
{
    public virtual string SmtpServer
    {
        get { return m_SmtpServer; }
        set { SetValue(ref m_SmtpServer, EmptyStringIfValueNull(value)); }
    }
}

public class DeviceConfigSMS : DeviceConfig
{
    public virtual string SmsServer
    {
        get { return m_SmsServer; }
        set { SetValue(ref m_SmsServer, EmptyStringIfValueNull(value)); }
    }

}

With the following Mapping file:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"  default-access="field.pascalcase-m-underscore">
  <class name="MyNamespace.DeviceConfig, MyNamespace" table="DeviceConfig" lazy="false">
      <id name="ID" access="property" column="DeviceConfigID" unsaved-value="-1">
      <generator class="identity" />
    </id>

    <discriminator column="Discriminator"/>

    <version name="Version" column="Version"/>

    <property name="Name" not-null="true"/>
    <property name="Description" not-null="true"/>


    <subclass name="MyNamespace.DeviceConfigEmail, MyNamespace" discriminator-value="Email" lazy="false">
      <property name="SmtpServer" not-null="true"  />
    </subclass>

    <subclass name="MyNamespace.DeviceConfigSMS, MyNamespace" discriminator-value="SMS" lazy="false">
      <property name="SmsServer" not-null="true"  />
    </subclass>

  </class>
</hibernate-mapping>

I am doing table per hierarchy data modelling to a table as follows:

table: DeviceConfig
- DeviceConfigID (PK, int, not null)
- Discriminator (varchar(20), not null)
- Name (varchar(50), not null)
- Description (varchar(200), not null)
- SmtpServer (varchar(30), null)
- SmsServer (varchar(30), null)

This is all well and good, and works against my SQL database.

I now want to do a SchemaExport to do some in memory testing against Sqlite. When I generate this table with a schema export, both SmtpServer and SmsServer columns get generated as not null.

Is there something I am doing wrong? How can I get these columns to generate as nullable?

Thanks,

Paul

  • 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-22T22:00:28+00:00Added an answer on May 22, 2026 at 10:00 pm

    You’ve set the columns as not null in the mapping:

    <property name="SmtpServer" not-null="true" />
    ....
    <property name="SmsServer" not-null="true" /> 
    

    Remove the not-null attributes.

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

Sidebar

Related Questions

Using the following classes.. public class Trait { public virtual int Id { get;
Is it possible to map an enum as a string using Fluent Nhibernate?
Using NHibernate.Mapping.Attributes, I have a entity class with something like: [Class] public class EntityA
my application has the following entity: public class User { public virtual int UserID
My application has the following entities: public class User { public virtual int UserID
I'm using NHibernate 2 and PostgreSQL in my project. SchemaExport class does a great
I've just started using Fluent NHibernate and have run into the following problem trying
I'm mapping a set of membership classes for my application using Fluent NHibernate. I'm
I have problem using Fluent Nhibernate, I have following model. When I try to
I am currently trying to map my Java class hierarchy into my database using

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.