These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Active Record with SQLite
PostPosted: Fri Oct 10, 2008 10:42 am 
Newbie

Joined: Tue Apr 17, 2007 10:07 am
Posts: 3
hi all,

on saving an active record base object to sqlite database, am getting the following exception:

InnerException: NHibernate.HibernateException
Message="The database returned no natively generated identity value"
Source="NHibernate"

although the record is being saved to the database.

The Configuration of Nhibernate is done as follows:

properties.Add("hibernate.connection.driver_class", "NHibernate.Driver.SQLiteDriver");
properties.Add("hibernate.dialect", "activeRecSQLite.CustomSQLiteDialect,activeRecSQLite");
properties.Add("hibernate.connection.provider", "NHibernate.Connection.DriverConnectionProvider");

properties.Add("hibernate.query.substitutions", "true=1;false=0");

properties.Add("hibernate.connection.connection_string", "Data Source=" + dbName + ";Version=3;New=False;Compress=True;");


Note that the CustomSQLiteDialect inherits from NHibernate.Dialect.SQLiteDialect class to override SupportsIdentityColumns function to avoid getting "no such table hibernate_primarykey" exception.(solution from http://forum.hibernate.org/viewtopic.ph ... 709c37e6d5 issue)

the database is beiing created from SQLitepro2008 and the id of the table is set to be Integer and Primary key.

Any help with this issue is very appreciated.
Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 13, 2008 3:36 am 
Newbie

Joined: Tue Apr 17, 2007 10:07 am
Posts: 3
I could solve the exception by specifying the type of primary key to Increment:

[PrimaryKey(PrimaryKeyType.Increment)], the incrementation for the primary key will be then on the client side before inserting the record into the db.

This annotation solves too the Message="no such table: hibernate_unique_key" exception, so it is no need to create a custom dialect class, the NHibernate.Dialect.SQLiteDialect can be used.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.