-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: generated database schema uses null column as primary key
PostPosted: Sun Jan 25, 2009 4:50 pm 
Newbie

Joined: Sun Jan 25, 2009 4:37 pm
Posts: 3
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
)
)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.