I'm currently updating from NHibernate 1.2.1 to 2.0.1. I noticed that the database generation scripts generated by NHibernate set the ID column to "null" instead of "not null", which is not allowed on MS SQL Server 2008. NHibernate 1.2.1 used to generate the corrent "not null" column. NHibernate 2.0.1 generates "not null" only for derived classes (joined subclass). Is this a bug, or do I have to tell NHibernate explicitly that ID columns should not be "null"?
Hibernate version:
NHibernate 2.0.1
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Refux.Core.Statistics" assembly="Refux.Core.Statistics">
<class name="Summary" table="Statistics_Summary">
<cache usage="nonstrict-read-write" region="Statistics"/>
<id name="Id">
<column name="Statistics_Summary_Id" sql-type="uniqueidentifier" not-null="true"/>
<generator class="guid.comb" />
</id>
[...]
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Refux.Core.Statistics.Summaries" assembly="Refux.Core.Statistics">
<joined-subclass name="Daily" extends="Refux.Core.Statistics.Summary" table="Statistics_Summaries_Daily">
<key column="Statistics_Summary_Id"/>
</joined-subclass>
</hibernate-mapping>
Name and version of the database you are using:
Microsoft SQL Server 2008 Express
The generated SQL (show_sql=true):
create table Statistics_Summary (
Statistics_Summary_Id uniqueidentifier null,
[...]
primary key (
Statistics_Summary_Id
)
)
create table Statistics_Summaries_Daily (
Statistics_Summary_Id UNIQUEIDENTIFIER not null,
primary key (
Statistics_Summary_Id
)
)
|