Hi!
Assume I had a base class "template" and a class "document" derived
thereof. And that I wanted to store both in a single table
(table-per-hierarchy):
<class name="Template" table="Templates" discriminator-value="0">
<id name="Id">
<generator class="assigned" />
</id>
<discriminator formula="(case when TemplateId is null then 0 else 1 end)" />
<property name="Name" not-null="true" />
<property name="FlowText" not-null="true" />
</class>
<subclass name="Document" extends="Template" discriminator-value="1">
<property name="PublishDate" not-null="true" />
<property name="Author" not-null="true" />
</subclass>
As you can see, "Document", the derived class, defines some non-nullable
properties.
Now when I use NHibernate.Tool.hbm2ddl.SchemaExport to let NHibernate
initialize a temporary in-memory SQLite database for me, the
"PublishDate" and "Author" columns are defined as not nullable. This
causes a "GenericADOException" exception when I attempt to insert a
"Template" object into the database ('abort due to constraint violation:
Templates.PublishDate may not be NULL').
I can work around this by removing the 'not-null' from my mappings, but
shouldn't NHibernate's SchemaExporter see that the table is shared with
another type and automatically declare any properties only appearing in
the derived class as nullable?
Merry Christmas, btw :)
-Markus-
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.