I'm using BigDecimal datatypes in my POJOs against a MySQL 4.0.14 using InnoDB table handlers.
My first problem is that the default DDL generated for them is as follows:
Code:
quantity NUMERIC(19, 255)
That isn't particular big as decimals go is it? I've heard they got a lot bigger.
I can get round that by explicitly setting the column type as follows so it's not a major problem:
Code:
quantity DECIMAL(60, 0)
The second problem actually seems to be an issue with MySQL but at this tage I don't know if it's a feature or bug. It may well have an impact on Hibernate's sql generation. It can be demonstrated by running the following against MySQL 4.0.14, I've not yet tried any later versions but it doesn't occur on MySQL v3.
Code:
DROP TABLE IF EXISTS TEST_TABLE;
CREATE TABLE TEST_TABLE (
quantity decimal(60,0)
) TYPE=InnoDB;
insert into TEST_TABLE values (10000000000000000000);
insert into TEST_TABLE values ('10000000000000000000');
On my version of MySQL the resulting table contains the following values:
Code:
-8446744073709551616
10000000000000000000
Obviously if Hibernate was wrapping BigDecimals in quotes then I wouldn't be experiencing the problem although I accept that that is probably a work-around for a MySQL problem rather than desired behaviour.
Should I raise this in JIRA or keep hammering away at MySQL?
Matt.
[/code]