Steps to re-create: 1) Create a DB table in your favorite DB, it should have at least one column with a scale of 2 eg:
CREATE TABLE `coupon_tbl` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `name` varchar(100) NOT NULL, `price` decimal(10,2) NOT NULL, PRIMARY KEY (`id`), ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2) Reverse engineer this table using hibernate tools and the column annotaion will look like this: @Column(name="price", nullable=false, precision=10)
3) Now when trying to use HSQL for testing, the create table script looks like: Hibernate: create table coupon_tbl (id bigint generated by default as identity (start with 1), name varchar(100) not null, price numeric(10,0) not null, store_id integer not null, primary key (id))
Now writing a price into this table causes the cents to be lost AND when comparing before and after prices, the scales of each of the BigDecimals are different, causing additional issues.
HSQL does not have a way to set the default scale, so I think that the column annotation code in BasicPOJOClass needs to not drop the scale and precision if they are 2 and 19 respectively. |
|