开发者

NHibernate not-null attribute has no effect

开发者 https://www.devze.com 2023-01-05 13:20 出处:网络
I\'m trying to add a column to an existing table. I added a property to the mapping : <property name=\"SelectionId\" column=\"selection_id\" not-null=\"true\"/>

I'm trying to add a column to an existing table. I added a property to the mapping :

<property name="SelectionId" column="selection_id" not-null="true"/>

When I open the session, the new column is created, however the not-null attribute is not taken into account : the new column is nullable.

I realize you need to specify a default value when adding a non-nullable column, but there is no default or default-value attribute for the <property> element... And anyway, I don't want a default value on this column : I want to set a specific value (0) for it on existing rows, but subsequent inserts wi开发者_开发技巧ll have to specify the value explicitly.

How can I make it work ? Do I have to do it manually in SQL ?

BTW, the underlying DBMS is SQLite, which has very limited support for ALTER TABLE (only add column and rename table are supported)...

0

精彩评论

暂无评论...
验证码 换一张
取 消