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 >= 0"/>
</property>
See Section 19.1 of the NHibernate documentation for more details.
精彩评论