SQLite 与 NHibernate 结合是否支持参照完整性/外键?

本教程将介绍SQLite 与 NHibernate 结合是否支持参照完整性/外键?的处理方法,这篇教程是从别的地方看到的,然后加了一些国外程序员的疑问与解答,希望能对你有所帮助,好了,下面开始学习吧。

SQLite 与 NHibernate 结合是否支持参照完整性/外键? 教程 第1张

问题描述

我已经阅读了一些关于 NHibernate with SQLite 的文章,认为当我需要轻量级数据库处理时它可能是一个非常好的选择.

我已经阅读了以下(和链接),其中讨论了 NHibernate SQLite 方言在创建数据库时怎么不支持外键,因为 NHibernate 通过 创建外键.p>

我想知道,如果我通过其他工具创建一个 SQLite 数据库,我能否将 NHibernate 与所述 SQLite 数据库一起使用,它会尊重参照完整性吗?

使用 SQlite 数据库启用 nHIbernate 的参照完整性

解决方案

NHibernate 3.1(当前可用的 GA 版本)及更早版本在通过 SchemaExport/SchemaUpdate 生成架构时不支持 FK.如果存在 FK,NHibernate 将使用它们.实际上数据库会使用它们,NHibernate 会将任何 FK 违规报告为 HibernateExceptions,就像任何其他数据库一样.

对使用 SQLite 生成 FK 的支持计划在 NHibernate 3.2 中发布.修复在后备箱中,特别是 R5543:

I have been reading a bit about NHibernate with SQLite, figuring it might be a very good option when I need lightweight database handling.

I've read the following (and the links) which talk about how the NHibernate SQLite dialect does not support foreign keys WHILE CREATING the database, since NHibernate creates foreign keys through .

I'm wondering, if I create an SQLite database through some other tool, would I be able to use NHibernate with said SQLite database, would it honor the referential integrity?

Enable referential integrity with nHIbernate using SQlite database

解决方案

NHibernate 3.1 (currently available GA release) and earlier do not support FKs when generating a schema through SchemaExport/SchemaUpdate. If FKs are present, NHibernate will use them. Actually the database will use them and NHibernate will report back any FK violations as HibernateExceptions, just like any other database.

Support for FK generation with SQLite is scheduled for release in NHibernate 3.2. The fix is in the trunk, specifically R5543:

N.B. This is my GitHub mirror of the official SVN repo on SourceForge.net. GitHub just does a nicer, faster job on formatting patches.

好了关于SQLite 与 NHibernate 结合是否支持参照完整性/外键?的教程就到这里就结束了,希望趣模板源码网找到的这篇技术文章能帮助到大家,更多技术教程可以在站内搜索。