views:

39

answers:

2

I have created a new 1.6 Sharp Architecture project.

I have marked my only Entity with HasUniqueDomainSignatureAttribute and one string property marked DomainSignatureAttribute.

I create 2 entities with the same DomainSignature and I'm able to save them both thous having duplicates.

Am I missing some configuration? As I was under the impression that this would work out of the box.

A: 

Before saving you should manually check entity for validness. I don't know how it is done now, but in previos versions each entitity had a property IsValid.

Sly
A: 

Well yes, the Validation method IsValid() is on the Entities.

But from the documentation I get the impression that if using NHibernate and NHibernate.Validators the repositories should validate the entities before Insert and Update. As in the documentation on nhforge.org

In SharpArch.Data.NHibernate.NHibernateSession following snippet is called each time Init() is used. Codes nippet from type HNibernateSession

Those things make me wonder why it doesn't work.

I could roll my own, but that seems like waste if it's already there.

Can anyone point me in the right direction? Also the SchemaExport util should use the validators when generating the scripts.

HAXEN
The NHibernateSession.Init has many overloads, one of which is to take in a string to the path of the validator config file. You would need to create this config file and pass it in as you do the NHibernate.config. The wiring would then work.
Alec Whittington
Thanks Alec! I found that, but then I had a error in my NHValidator.config file due to error in NHValidator documentation. Argh.Maybe the "sharp arch" wiki should contain some words in the matter? I would be happy to do it!
HAXEN