Does SQLite, in combination with NHibernate, support referential integrity / foreign keys?

I read a bit about NHibernate with SQLite, believing this could be a very good option when I need easy database handling.

I read the following (and links) that talk about how the NHibernate SQLite dialect does not support foreign keys. CREATING a database because NHibernate creates foreign keys through ALTER TABLE.

I am wondering if I create an SQLite database using any other tool, can I use NHibernate with the specified SQLite database, will it indicate referential integrity?

Enable referential integrity using nHIbernate using the SQlite database

+4
source share
1 answer

NHibernate 3.1 (the currently available release of GA) and previously do not support FK when creating schemas through SchemaExport / SchemaUpdate. If FK are present, NHibernate will use them. In fact, the database will use them, and NHibernate will report any FK violations as HibernateExceptions, like any other database.

Support for generating FK using SQLite is planned for release in NHibernate 3.2. The fix is ​​in the torso, in particular R5543:

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

NB This is my GitHub mirror of the official SVN repo at SourceForge.net. GitHub just does faster and faster work on formatting patches.

+3
source

Source: https://habr.com/ru/post/1345798/


All Articles