Does SQLite coupled with NHibernate support referential integrity / foreign keys?

荒凉一梦 提交于 2019-12-01 04:24:21

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/5479901/does-sqlite-coupled-with-nhibernate-support-referential-integrity-foreign-keys

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!