Does SQLite coupled with NHibernate support referential integrity / foreign keys?
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, woul开发者_运维问答d 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.
精彩评论