Note that there are some explanatory texts on larger screens.

plurals
  1. POnHiberbate: Table per hierarchy - SchemaExport problem
    primarykey
    data
    text
    <p>I am using nhibernate to map the following classes:</p> <pre><code>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)); } } } </code></pre> <p>With the following Mapping file:</p> <pre><code>&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-access="field.pascalcase-m-underscore"&gt; &lt;class name="MyNamespace.DeviceConfig, MyNamespace" table="DeviceConfig" lazy="false"&gt; &lt;id name="ID" access="property" column="DeviceConfigID" unsaved-value="-1"&gt; &lt;generator class="identity" /&gt; &lt;/id&gt; &lt;discriminator column="Discriminator"/&gt; &lt;version name="Version" column="Version"/&gt; &lt;property name="Name" not-null="true"/&gt; &lt;property name="Description" not-null="true"/&gt; &lt;subclass name="MyNamespace.DeviceConfigEmail, MyNamespace" discriminator-value="Email" lazy="false"&gt; &lt;property name="SmtpServer" not-null="true" /&gt; &lt;/subclass&gt; &lt;subclass name="MyNamespace.DeviceConfigSMS, MyNamespace" discriminator-value="SMS" lazy="false"&gt; &lt;property name="SmsServer" not-null="true" /&gt; &lt;/subclass&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre> <p>I am doing table per hierarchy data modelling to a table as follows:</p> <pre><code>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) </code></pre> <p>This is all well and good, and works against my SQL database.</p> <p>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 <strong>not null</strong>. </p> <p>Is there something I am doing wrong? How can I get these columns to generate as nullable?</p> <p>Thanks,</p> <p>Paul</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload