I have mapped a class hierarchy using a table per subclass and it
works with Sql Server 2005.
However, when I try to use this same mapping against a Sql Compact 4.0
db, the generated insert statement is not working because it does not
include any column or value.
I’m using NH3.1.0-GA and MsSqlCe40Dialect.
The insert statement generated is:
INSERT INTO Element values ( )
And the mapping:
<class name="IElement" table ="Element">
<id name="Id">
<generator class="identity"/>
</id>
<joined-subclass name="TextElement" table ="TextElement">
<key column="Id"/>
<property name="Text" length="200"/>
</joined-subclass>
<joined-subclass name="NumberElement" table="NumberElement">
<key column="Id"/>
<property name="Value"/>
</joined-subclass>
</class>
Thanks.
That’s definitely a bug (more precisely, a yet-unsupported scenario). I suggest you create an issue with a full repro test at http://jira.nhforge.org (you can link to this question)
The MSSQL syntax for a value-less insert is
INSERT INTO <table> DEFAULT VALUES. This is defined inMsSql2000Dialect.NoColumnsInsertString.The same code should probably be applied to
MsSqlCe40Dialect(orMsSqlCeDialectif this syntax was available in previous versions, which I don’t know).As a workaround, just inherit from
MsSqlCe40Dialectand add the following:Of course, I’m assuming that is the correct syntax for SQL CE 4.