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>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to