Hi You sure you have well configurated your NHibernate.Validator with NHibernate integration?
If you're not sure, you can do new ValidatorEngine().IsValid(myObject); if this is validating OK, then the integration with NH is wrong. Have a look where it says Configuration http://nhforge.org/wikis/validator10/nhibernate-validator-1-0-0.aspx On Mon, Feb 2, 2009 at 1:48 PM, Michael Meadows <mwmead...@gmail.com> wrote: > > I am having a problem using NHibernate.Validator. The class I am > saving has a class property, and it has a string property which is > null. The string property is specified not-null in the class xml > file, and it has a [NotNull] attribute in the class cs file. > > I am getting a HibernateException "not-null property references a null > or transient value". I expected to get an InvalidStateException but > it seems like the validator is not getting called before NHibernate > tries to insert it. > > Any idea where I'm going wrong? > > Relevant files: > > <?xml version="1.0" encoding="utf-8" ?> > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > namespace="CB.BusinessObjects" assembly="BusinessObjects" default- > lazy="false"> > <class name="FilterSet"> > <id name="ID" type="Guid"> > <generator class="guid.comb"/> > </id> > <version name="Version"/> > <component name="FiscalYear" > class="CB.BusinessObjects.FilterFiscalYear, BusinessObjects"> > <property name="ExcludedMonth"/> > <property name="ExcludedYear"/> > </component> > </class> > </hibernate-mapping> > > <?xml version="1.0" encoding="utf-8" ?> > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > namespace="CB.BusinessObjects" assembly="BusinessObjects" default- > lazy="false"> > <class name="FilterFiscalYear"> > <id name="ID" type="Guid"> > <generator class="guid.comb"/> > </id> > <version name="Version"/> > <property name="ExcludedMonth" column="ExcludedMonth" not- > null="true" /> > <property name="ExcludedYear" column="ExcludedYear" not- > null="true" /> > </class> > </hibernate-mapping> > > <?xml version="1.0" encoding="utf-8" ?> > <nhv-configuration xmlns='urn:nhv-configuration-1.0'> > <property name='apply_to_ddl'>true</property> > <property name='autoregister_listeners'>true</property> > <property name='default_validator_mode'>UseAttribute</property> > <mapping assembly="BusinessObjects"/> > </nhv-configuration> > > <?xml version='1.0' encoding='utf-8'?> > <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> > <session-factory> > <property > name="connection.provider">NHibernate.Connection.DriverConnectionProvider</ > property> > <property > name="connection.driver_class">NHibernate.Driver.SqlClientDriver</ > property> > <property name="show_sql">true</property> > <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</ > property> > <property name="use_outer_join">true</property> > <property name="use_proxy_validator">false</property> > <mapping assembly="BusinessObjects"/> > </session-factory> > </hibernate-configuration> > > > > > > -- Dario Quintana http://darioquintana.com.ar --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---