SQLite加NHibernate是否支持引用完整性/外键? [英] Does SQLite coupled with NHibernate support referential integrity / foreign keys?

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

问题描述

我一直在用SQLite阅读一下NHibernate,认为这可能是一个非常好的选择,当我需要轻量级的数据库处理的时候。



我读过以下(和链接),讨论NHibernate SQLite方言不支持外键WHILE CREATING数据库,因为NHibernate通过 ALTER TABLE 创建外键。

我想知道,如果我通过其他工具创建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



注意这是我在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天全站免登陆