Do you mean within the normal NHibernate mapping file? Yes it works.
And I can give the constraints with the validator to simple properties
of a class. But if I have a subclass, and if I map it with the
validator,
constraints won't be added to the schema. I have mapped the subclass
as a component in the NHibernate configuration.

I noticed I needed to add the "valid" tag to all subclasses if I
wanted
them to be included in the validation. Is there something similar that
needs to be added in the case of schema generation?

On Jul 27, 9:17 pm, James Gregory <[email protected]> wrote:
> Have you tried specifying the columns explicitly? Then applying the length
> attribute to those.
>
> On Mon, Jul 27, 2009 at 3:44 PM, mikoro <[email protected]> wrote:
>
> > Hi,
>
> > I've been having some problems getting the right schema generated.
> > Here's an example class (stripped versions):
>
> >        public class User
> >        {
> >                public virtual Guid Id { get; private set; }
>
> >                public virtual Names Names
> >                {
> >                        get { return names; }
> >                        set { names = value; }
> >                }
>
> >                private Names names = new Names();
> >        }
>
> >        public class Names
> >        {
> >                public virtual string FirstName
> >                {
> >                        get { return firstName; }
> >                        set { firstName = value; }
> >                }
>
> >                private string firstName = string.Empty;
>
> >                ...
> >        }
>
> > Then I have this kind of validation mapping:
>
> >        <class name="User">
> >                <property name="Names">
> >                        <not-null/>
> >                        <valid/>
> >                </property>
> >        </class>
>
> > Now whatever constraints I then go and put on the properties of the
> > Names class, they wont show up in the schema. Strings are always
> > nvarchar(255) null etc. What I'm doing wrong?
--~--~---------~--~----~------------~-------~--~----~
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