Seting up NHibernate Validator with Spring.net
-
06-09-2019 - |
Question
How can I setup NHibernate Validator with Spring.net as IoC?
I am already using Spring.net integration with NHibernate and can't get AutoRegisterListeners to work.
What I need is to setup NHV to validate entities automatically upon Update/Save instead of having to call Validate method every time and use Spring.net with ISharedEngineProvider to make sure optimal performance.
Solution
After looking around a lot I found this one: http://forum.springframework.net/showthread.php?t=5286
I'm repeating it here for others to find it easier that I did!:
<object id="sessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate20">
<!-- the usual properties ... -->
<!-- event listeners -->
<property name="EventListeners">
<dictionary>
<entry key="PreUpdate">
<object type="NHibernate.Validator.Event.ValidatePreUpdateEventListener, NHibernate.Validator" />
</entry>
<entry key="PreInsert">
<object type="NHibernate.Validator.Event.ValidatePreInsertEventListener, NHibernate.Validator" />
</entry>
</dictionary>
</property> </object>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow