开发者

Check constraints in NHibernate

Is there a way to have NHibernate's SchemaExport generate check constraints defined in its .hbm.xml files? Or is that not really part of its domain?

Either way, how can I, in combination with NHibernate's SchemaE开发者_如何学编程xport, add check constraints to the schema it generates so as to run my unit tests properly.


Yes. When you define your property mapping, you can define a column and identify a constraint via the check attribute.

<property name="count" not-null="true" >
  <column name="count" check="count &gt;= 0"/>
</property>

See Section 19.1 of the NHibernate documentation for more details.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜