Hi,

I guess the problem is that for java.math.BigDecimal, hashCode (used for
union) and compareTo (used for join) are a bit strange. See also the
javadocs: "Note that two BigDecimal objects that are numerically equal but
differ in scale (like 2.0 and 2.00) will generally not have the same hash
code.".

I'm not sure how to best fix this problem.

Regards,
Thomas


On Thursday, November 6, 2014, Jiunn Jye Ng <[email protected]> wrote:

> Hi All,
>
> I am testing the scenario is of union of Integer and Decimal.
> Observation is H2 does not merge the value when column is defined
> as decimal with scale and the numeric value are the equal.
>
> Test Integer Union Decimal (5):
>    select cast (1 as integer) from dual
>    union
>    select cast (1 as decimal(5)) from dual;
> => Result are merged
>
> Test Integer Union Decimal (5,1):
>    select cast (1 as integer) from dual
>    union
>    select cast (1 as decimal(5,1)) from dual;
> => Result are NOT merged
>
> Same behavior is observed when union decimal / decimal with scale
> Test Decimal(5) Union Decimal (5,1):
>    select cast (1 as decimal(5)) from dual
>    union
>    select cast (1 as decimal(5,1)) from dual;
> => Result are NOT merged
>
> Test Join
>    select * from
>       (select cast (10 as decimal(5)) col1 from dual ) a,
>       (select cast (10 as decimal(5,1)) col1 from dual) b
>    where a.col1 = b.col1;
> => value can be join
>
> Is this a defect ?
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <javascript:_e(%7B%7D,'cvml','h2-database%[email protected]');>
> .
> To post to this group, send email to [email protected]
> <javascript:_e(%7B%7D,'cvml','[email protected]');>.
> Visit this group at http://groups.google.com/group/h2-database.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to