2008/10/4 orjan <[EMAIL PROTECTED]> > > However I don't understands Fabios post, except for the tears, about > the SharedEngineProvider is it possible to avoid the steps in Gustavos > post? >
No if you want NHV auto-change mappings to inject constraint for SchemaExport. The SharedEngineProvider is an "option". You can work with or without the SharedEngine. The advantage is that you can share the ValidatorEngine with NH that mean: 1) the engine is initialized at BuildSessionFactory by NH 2) You are sure that all NH validate trough listeners is the same of you are validating in other tears. 3) there is only one instance of ValidatorEngine The ValidatorEngine hold all validators of each entity. When you initialize NHV what you are doing is investigate all you entities at startup. As you probably know the ValidatorEngine can work without configuration, if you respect some conventions, but configure it is part of best-practices as use SharedEngine where your application infrastructure allow it. If you don't use SharedEngineProvider both listeners (PreInsert and PerUpdate) will share the same engine (to don't have two instances of it) but your application don't use the same engine. In short try this: In the app config put this: <nhv-configuration xmlns='urn:nhv-configuration-1.0'> <shared_engine_provider class='NHibernate.Validator.Event.NHibernateSharedEngineProvider, NHibernate.Validator'/> </nhv-configuration> And then: var cfg = new Configuration(); cfg.Configure(); cfg.AddAssembly(typeof (Fish).Assembly); ValidatorEngine engine = NHibernate.Validator.Cfg.Environment.SharedEngineProvider.GetEngine(); engine.Configure(); ValidatorInitializer.Initialize(cfg); new SchemaExport(cfg).Execute(true, true, false, true); sessions = cfg.BuildSessionFactory(); Your full initialized engine is available in NHibernate.Validator.Cfg.Environment.SharedEngineProvider.GetEngine(); If you don't set the SharedEngineProvider in the app config, and you want use SharedEngine with listeners, you can do: var cfg = new Configuration(); cfg.Configure(); cfg.AddAssembly(typeof (Fish).Assembly); ValidatorInitializer.Initialize(cfg); new SchemaExport(cfg).Execute(true, true, false, true); Cfg.Environment.SharedEngineProvider = new NHibernateSharedEngineProvider(); sessions = cfg.BuildSessionFactory(); Another time your full initialized engine is available in NHibernate.Validator.Cfg.Environment.SharedEngineProvider.GetEngine(); If you don't need or you can't use the SharedEngine is enough with: var cfg = new Configuration(); cfg.Configure(); cfg.AddAssembly(typeof (Fish).Assembly); ValidatorInitializer.Initialize(cfg); new SchemaExport(cfg).Execute(true, true, false, true); sessions = cfg.BuildSessionFactory(); And then create (initialize if you want) and use your engine where you want. -- Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
