We know that the database storage money type can be float, double, decimal, compared to decimal is the best use.
Well, our company is divided into units, type with bigint access, operation of the time to is very convenient, when the show will have to turn.
The result is a bug.
Look at the problem first,
The database reads money and retains two decimal places.
<SelectId="Findsummoney" Resulttype="Java.lang.Double"> SELECTFORMAT (Ifnull (sum( Money),0)/ -,2) fromR_orderWHEREUID=#{uid} andState= 1 andPay_typeinch(1,2, A) GROUP byUID</Select>
As a result, when money is greater than 1000, it is converted into 1,000.00 by format.
The program then hits the exception. Can not be converted to this type, the original conversion method is greater than 1000, automatically add a comma to the string type, double cannot receive, because do not want to change the code,
In the end, use the CONVERT function:
<SelectId="Findsummoney" Resulttype="Java.lang.Double"> SELECT Convert(Ifnull (sum( Money)/ -,0),DECIMAL(9,2)) fromR_orderWHEREUID=#{uid} andState= 1 andPay_typeinch(1,2, A) GROUP by#{uid}</Select>
The resolution returned is 1000.00
MySQL If processing currency money type