i want persist sum of double values decimal(4,2) in database , display user. issue have is, decimal number stored correctly in database 2 decimal digits. when querying database in cases displays lot more decimal digits user. in entity class have:
@column(name="weight_sum", precision=6, scale=2) private double weightsum;
in mysql database have column specified
decimal (4,2)
i don't understand made mistake.
actually doing correct things need more stuff. if have define precision , scale weightsum of entity class save db accordingly. when data db , bind corresponding entity class again take default scale(actual scale following zero) , precision value. whenever send data end user need set scale as-
weightsum.setscale(2, bigdecimal.round_floor)
;
in above method 2nd parameter roundingmode
, should select roundingmode per requirement.
i hope out. thanks
Comments
Post a Comment