SQLite 与 NHibernate 结合是否支持参照完整性/外键? [英] Does SQLite coupled with NHibernate support referential integrity / foreign keys?

查看:36
本文介绍了SQLite 与 NHibernate 结合是否支持参照完整性/外键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

解决方案

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

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

https://github.com/JamesKovacs/nhibernate/commit/2711450b8fcea66df41699ac595b4cc814d7f64b>/p>

注意这是我在 SourceForge.net 上的官方 SVN 存储库的 GitHub 镜像.GitHub 在格式化补丁方面做得更好、更快.

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 ALTER TABLE.

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:

https://github.com/JamesKovacs/nhibernate/commit/2711450b8fcea66df41699ac595b4cc814d7f64b

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 结合是否支持参照完整性/外键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆