Hi Rainer, thanks for your answer.
I think it's different because double and int are native types and they can't be null, while BigDecimal is an Object which can be null. You are right, calculations are safer, but this means that calculations can return wrong result. For example if an investor has 1000 IBM shares and wan't to know it's market value, the program will multiply it with the current price. If there is no price in the db it will return 0 instead of throwing an exception that the market value can't be calculated. That's why we use in our model BigDecimal, Double etc. types as numerics, not native types. Anyway this problem exists with Resultset's getDouble() etc. methods, so we already read numeric values with methods checking null values, so this is not a big problem for us, it was just a question. Thanks, Ivan On Fri, Sep 19, 2014 at 10:49 AM, Rainer Döbele <[email protected]> wrote: > Hello Ivan, > > the idea behind getDecimal() not returning null is that we want to treat > it like a native data type similar to int and double. For those two we > cannot return null anyway, so why should we treat a decimal differently? > This makes calculations in code more readable as in fact in math operations > we can safely assume that a non existing number should be treated like zero. > > I you need to know I would recommend that you call isNull(…) to determine > if the value is not supplied. > > Alternatively you always have the opportunity to call getValue() and check > for null and if not do the type conversion yourself. > > Regards > > Rainer > > > > *Von:* [email protected] [mailto:[email protected]] *Im Auftrag > von *ivan nemeth > *Gesendet:* Donnerstag, 18. September 2014 12:37 > *An:* user > *Betreff:* Re: Decimal Datatype with scale 10 > > > > Hi Rainer, > > > > thanks for the info. > > > > We're developing financial applications for fund management companies and > prices are stored with scale 10 in our databases, and so our code is based > on this. It will be a lot of work to change it in our code, so if it will > be fixed it's a good news for me. (Until then I subclassed DBTableColumn > which overrides the validateNumber method, which caused the main problem.) > > > > Other question regarding DECIMAL types.Why does the the > DBRowSetData.getDecimal() method return BigDecimal.ZERO (and not null like > in Java ResultSet) when the db value is NULL? There is a clear difference > between a null value and a ZERO value. > > > > Thanks, > > Ivan > > > > > > > > On Thu, Sep 18, 2014 at 9:05 AM, Rainer Döbele <[email protected]> wrote: > > Hi Ivan, > > > > this issue has already been reported. > > Here’s the corresponding JIRA ticket: > > https://issues.apache.org/jira/browse/EMPIREDB-208 > > > > At the moment I cannot offer a solution but we’re working on it. > > > > Just for curiosity: > > What application do you need that for? > > i.e. what kind of information are you storing in that decimal and why do > you need such long scales? > > > > Regards > > Rainer > > > > > > *from:* [email protected] [mailto:[email protected]] *Im Auftrag > von *ivan nemeth > *to:* user > *re:* Decimal Datatype with scale 10 > > > > Hi, > > > > how can I define a DECIMAL column with scale 10? > > > > Thanks, > > Ivan > > >
