Be careful! The precision details are missing when a string is used for SQL statement operations !, SQL missing
I did not update it yesterday. I would like to explain the reason. It was very late when I returned home yesterday. The projects in the company were quite tight over the past few days (there were many bugs, so I was eager to catch up with the demand, my heart trembled.) I didn't prepare materials in time. Today I added another class (I am still in the company, and I have to steal a gap to send a blog, hahaha), so I didn't make any changes last night.
I found a small problem when I changed the bug today. I 'd like to share it with you, but I should be careful.
We have a page where you need to input numbers to the backend, perform related operations, and then query the calculated numbers. The input values on the page are input to the backend of the String type, after calculation, a value with missing precision is obtained, which is converted to the Integer type during query, resulting in an error. The following figure shows the operation result:
Price is of the Decimal type, and 100 is the value passed in by the input on the page. The third column is the conversion result after locating the problem with a colleague, and no error will be reported if the query is performed.
When you need to calculate the page input values in the background later, especially in SQL statements, remember to check the input value type or add "jdbcType =? "To conduct monitoring, in case of errors, to quickly locate and speed up development efficiency (the original development engineer did not write, I and my colleagues located for half an hour to find, I am angry with me, this operation, an error is reported only when the price is a decimal number. The integer value is correct.) Well, today we are here. I'm off duty first, and today the bug is almost changed, happy mood.
My wish is to change the world!