views:

145

answers:

2

Hello,

I am using nhibernate for my OR persistence and I store a list of doubles into a table using the following mapping (where the list is embedded in another class).

<list name="Values" access="field" table="Values_double" >
  <key column="variable_id"/>
  <index column="no_data_values_list_index"/>
  <element column="value"  type="System.Double"/>
</list>

This works fine except when I try to store double.MinValue or double.MaxValue. I get an error when reloading from my DB saying:

System.OverflowException: Value was either too large or too small for a Decimal.

Which seems to be related to NHibernate storing the doubles as 'NUMERIC' values in my sqlite dBase. The conversion back seems to go broke. Any suggestions are very welcome.

Greetings, Martijn

A: 

I have no experience with SQLite, but you can override NHibernate's choice of SQL datatype by using the sql-type attribute in the mapping. This might help if NUMERIC is not appropriate for the given circumstance.

For example:

<property name="Foo" type="String">
    <column name="foo" length="64" not-null="true" sql-type="text"/>
</property>
Erik Öjebo
Thanks for your suggestion...but non of the types i have present in sqlite provide good persistence of maxvalues...
Gluip
This doesn't seem to be compatible with NHibernate 1.2 :(
Ekevoo
A: 

In the end I solved it by introducing another custom IUserType for this simple problem :(

Gluip