How to use Nhibernate Validator + NHib component + ddl

483 views Asked by At

I just configured my NHibValidator. My NHibernate creates the DB schema. When I set MaxLenght="20" to some property of a class then in the database the length appears in the database column. I am doing this in the NHibValidator xml file. But the problem is that I have components and cannot figure out how to achieve this behaviour. The component is configured correctly in the Customer.hbm.xml file.

EDIT: Well, I found that Hibernate Validator users had the same problem two years ago. http://opensource.atlassian.com/projects/hibernate/browse/HV-25 Is this an issue for NHibernate Validator or it is fixed. If it is working tell me how please.

-----------------------------------------------------
public class Customer
{
public virtual string Name{get;set;}
public virtual Contact Contacts{ get; }
}
-----------------------------------------------------
public class Contact
{
public virtual string Address{get;set;}
}
-----------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<nhv-mapping xmlns="urn:nhibernate-validator-1.0"
                        namespace="MyNamespace"
                        assembly="MyAssembly">
<class name="Customer">

   <property name="Name">
     <length max="20"/>
   </property>

   <property name="Contacts">
         <notNull/>
         <valid/>
   </property>

</class>
</nhv-mapping>
-----------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<nhv-mapping xmlns="urn:nhibernate-validator-1.0"
                        namespace="MyNamespace"
                        assembly="MyAssembly">
<class name="Contact">

   <property name="Address">
         <length max="50"/>
         <valid/>
   </property>

</class>
</nhv-mapping>
-----------------------------------------------------
1

There are 1 answers

0
mynkow On BEST ANSWER

Well, this should be a bug. I posted this to NHibernate issue tracker.

https://nhibernate.jira.com/browse/NHV-82

UPDATE: the issue is solved.