开发者

How to use Nhibernate Validator + NHib component + ddl

开发者 https://www.devze.com 2022-12-13 10:11 出处:网络
I just configured my NHibValidator. My NHibernate creates the DB schema. When I set MaxLenght=\"20\" to some property of a class then in

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"/>
   </pr开发者_开发百科operty>

   <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>
-----------------------------------------------------


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消