首页 \ 问答 \ NHibernate Validator没有与Fluent NHibernate集成(NHibernate Validator not integrating with Fluent NHibernate)

NHibernate Validator没有与Fluent NHibernate集成(NHibernate Validator not integrating with Fluent NHibernate)

我在让NHV与Fluent NHibernate合作时遇到了一些麻烦。 我拥有的单元测试有一个应该失败的实体,最终会抛出一个ADO异常。 我有以下方式配置NHV:

    private static void Init()
    {
            _SessionFactory = Fluently.Configure()
              .Database(MsSqlConfiguration.MsSql2005.ConnectionString(connectionString)
                  .ShowSql())
              .Mappings(m =>
                  m.FluentMappings.AddFromAssemblyOf<SessionFactory>()
                  .ExportTo(pathToExportMappingsTo))
              .ProxyFactoryFactory("NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu")
              .ExposeConfiguration(ConfigureNhibernateValidator)
              .BuildSessionFactory();
    }

    private static void ConfigureNhibernateValidator(Configuration config)
    {
        var nhvConfiguration = new NHibernate.Validator.Cfg.Loquacious.FluentConfiguration();
        nhvConfiguration
           .SetDefaultValidatorMode(ValidatorMode.OverrideAttributeWithExternal)
           .Register(Assembly.Load("Business.Objects")
           .ValidationDefinitions())
           .IntegrateWithNHibernate
               .RegisteringListeners();

        ValidatorEngine validatorEngine = new ValidatorEngine();
        validatorEngine.Configure(nhvConfiguration);

        ValidatorInitializer.Initialize(config, validatorEngine);
    }

我现在已经多次查看过这个配置并搜索了互联网,试图找出这个问题。 我还查看了NHV源中提供的示例,但我无法弄清楚为什么我的单元测试不会抛出InvalidStateException。 我有一个单元测试来验证应该失败的同一个实体,它通过验证引擎直接验证它,这是有效的。

有没有人看到上述配置有什么问题?

我正在使用NHibernate 3.1NHibernate Validator 1.3Fluent NHibernate 1.2.0.712


I'm having some trouble getting NHV to work with Fluent NHibernate. A unit test that I have that has an entity that SHOULD be failing validation ends up throwing an ADO exception. I have NHV configured the following way:

    private static void Init()
    {
            _SessionFactory = Fluently.Configure()
              .Database(MsSqlConfiguration.MsSql2005.ConnectionString(connectionString)
                  .ShowSql())
              .Mappings(m =>
                  m.FluentMappings.AddFromAssemblyOf<SessionFactory>()
                  .ExportTo(pathToExportMappingsTo))
              .ProxyFactoryFactory("NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu")
              .ExposeConfiguration(ConfigureNhibernateValidator)
              .BuildSessionFactory();
    }

    private static void ConfigureNhibernateValidator(Configuration config)
    {
        var nhvConfiguration = new NHibernate.Validator.Cfg.Loquacious.FluentConfiguration();
        nhvConfiguration
           .SetDefaultValidatorMode(ValidatorMode.OverrideAttributeWithExternal)
           .Register(Assembly.Load("Business.Objects")
           .ValidationDefinitions())
           .IntegrateWithNHibernate
               .RegisteringListeners();

        ValidatorEngine validatorEngine = new ValidatorEngine();
        validatorEngine.Configure(nhvConfiguration);

        ValidatorInitializer.Initialize(config, validatorEngine);
    }

I've looked over this configuration several times now and scoured the internet to try and find out what's wrong with this. I've also looked at examples provided in the NHV source but I haven't been able to figure out why my unit test does not throw an InvalidStateException. I have a unit test to validate the same entity that should be failing that validates it directly via the validation engine and this works.

Does anyone see anything wrong with the above configuration?

I'm using NHibernate 3.1, NHibernate Validator 1.3 and Fluent NHibernate 1.2.0.712


原文:https://stackoverflow.com/questions/5590250
更新时间:2022-03-01 07:03

最满意答案

您需要定义正确的ComponentName:

new ComponentName("com.valecast.myapp", "com.valecast.myapp.SecondaryActivity");

试试看:

try {
    ActivityInfo info = pm.getActivityInfo(cn, 0);
} catch (PackageManager.NameNotFoundException e) {
    e.printStackTrace();
}

You need to define the proper ComponentName:

new ComponentName("com.valecast.myapp", "com.valecast.myapp.SecondaryActivity");

and have a try catch:

try {
    ActivityInfo info = pm.getActivityInfo(cn, 0);
} catch (PackageManager.NameNotFoundException e) {
    e.printStackTrace();
}

相关问答

更多
  • 毕竟这是给tv提的概念,这个行业还是比较少人在接触: Android TV中,更多被提及的是“Leanback”,这个“Leanback”就是指以放松的姿势倒在沙发上,也就是强调了不同于如智能手机等“以主观动向”为主的使用方式。 在基调演讲中,Google的UI开发者Matias Duarte引用了以下的这句话。“When your butt hits the sofa you lose 20 IQ point。”(当你的屁股挨着沙发时,你的IQ就降低了20)虽然这种说法有点不雅,但事实确实如此。无论是谁, ...
  • 我认为您可以在移动设备上使用某种PIN码。 例如,当用户需要登录时,他们可以选择在电视中登录,或输入显示在已登录的移动应用程序上的某些PIN码。 I think you can use some kind of PIN code with your mobile device. For example, when user need to log in, they can choose login in TV, or enter some PIN code that display on your mobi ...
  • 总之:不。 BrowseFragment和DetailsFragment旨在为开发人员提供内容到电视的快速而简单的方法。 他们强迫你去那个特定的结构,这很容易理解和导航。 如果您愿意全力以赴进行自定义体验,则需要使用HeadersFragment和RowsFragment构建您的BrowseFragment版本。 这证明是相当头疼的 ,但我设法为我的公司的应用做到了。 如果你有兴趣,我会写一篇关于此的文章/文章。 编辑 这是文章 ! 如果你想看一看,它是Android TV的一个更大的集合的一部分。 In ...
  • 在创建/初始化对象时,您不能使用Service (或该事件的Activity )作为Context 。 相反,重写onCreate()并在那里进行初始化并摆脱显式构造函数。 You cannot use a Service (or an Activity for that matter) as a Context when the object is being created/initialized. Instead, override onCreate() and do your initializat ...
  • 这是一个不受支持的黑客,但它将完成工作。 您可以在项目的colors.xml文件中将颜色lb_speech_orb_recording覆盖为颜色。 然后它看起来像下面的图像: This is an unsupported hack, but it'll get the job done. You can override the color lb_speech_orb_recording as a color in your colors.xml file in your project. Then it ...
  • GuidedStepSupportFragment (扩展android.support.v4.app.Fragment )在leanback从27.1.0开始 There is GuidedStepSupportFragment (extends android.support.v4.app.Fragment) in leanback starting from 27.1.0
  • 在您的活动内部扩展BrowseFragment,这将删除左侧抽屉的标题... setHeadersState(HEADERS_DISABLED); 如果您使用的是Android TV示例应用程序,则可以通过以下方法在MainFragment类中进行... setupUIElements() Inside of your activity that extends BrowseFragment, this will remove the left drawer with the headings... s ...
  • 在非活动类的构造函数中获取Context的实例,并使用它来调用所有此类方法。 像这样的东西: public class NonActivityClass implements SensorListener{ Context mContext; public NonActivtiyClass(Context context) { this.mContext = context; } //Rest of your code } 然后执行此操作以在Activtiy的onCreate()创建该类的对象: NonA ...
  • 您需要定义正确的ComponentName: new ComponentName("com.valecast.myapp", "com.valecast.myapp.SecondaryActivity"); 试试看: try { ActivityInfo info = pm.getActivityInfo(cn, 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } You need t ...
  • 与Leanback几乎所有东西一样,有不止一种方法可以给猫皮肤涂抹。 我们需要自定义ListRow以向标头添加更多填充。 我们通过覆盖onBindRowViewHolder的ListRowPresenter实现了这种级别的自定义,抓取了标题的View (通过View header = holder.getHeaderViewHolder().view; )。 然后我们用header.getLayoutParams().height = rowItem.getRowHeaderHeight();更改了它的高度 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)