views:

45

answers:

2

I'm learning to use NHibernate validator and it's Fluent API (Loquacious).

I have noticed is that I can't set an integer property or nullable int property (int?) to be not nullable. Well, why not?

In a database, an integer column can have null values. Even worse, when I generate DDL using SchemaExport, the integer column wont be picking up that non-nullabity (unless I express it in the Nhibernate mappings).

A: 

You gave the answer already. The validator is not scanned by schema export. You have to use the mapping.

Paco
A: 

NHibernate Validator sits on top of NHibernate. It is used to validate entities against NHibernate mappings and custom rules. For configuring field properties, such as whether they are nullable, this is done in the NHibernate mappings as it affects not only the validations done, but also the generated SQL statements.

Matthew Kubicina