0

I have a C# System.Double property which may contains value like 1e250 :

public virtual double DoubleValue {get; set;}

The property is mapped to a BINARY_DOUBLE column :

<property name="DoubleValue" column="VALUE_BINARY_DOUBLE"/>

Max value for Binary_Double is about 1.7e+308 (Oracle doc), but I'm getting an exception :
ORA-01426 : numeric overflow

Problem appears even when executing a query through SQL+. I have to use the TO_BINARY_DOUBLE cast to make it work. In my understanding, the number supplied is implicitly converted to a NUMBER : my query work with 1e125 (max for NUMBER is 1e126) but won't work with 1e250.

I've also tried those mappings, without success :

<property name="DoubleValue" column="VALUE_BINARY_DOUBLE" type="System.Double"/>
<property name="DoubleValue" column="VALUE_BINARY_DOUBLE" type="binary"/>

Using : Oracle 11G - NHibernate 2.1.0 - .Net 3.5 SP1

Thanks for any lead you may provide !

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
Vivien Ruiz
  • 618
  • 3
  • 11

1 Answers1

0

Here is the workaround we are using, since we didn't find any solution :
Add a property in C# :

public virtual string DatabaseDoubleValue
{
    get
    {
        return DoubleValue.ToString();
    }
    set
    {
        DoubleValue = double.Parse(value);
    }
}

Change mapping to

<property name="DatabaseDoubleValue" column="VALUE_BINARY_DOUBLE"/>

Add a trigger on the VALUE_BINARY_DOUBLE column :

FOR EACH ROW
BEGIN
    :NEW.VALUE_BINARY_DOUBLE := TO_BINARY_DOUBLE(:NEW.VALUE_BINARY_DOUBLE);
END;

Works fine that way!

Vivien Ruiz
  • 618
  • 3
  • 11