Home > Back-end >  Mybatis sort for an integer types of data when ordering how do sorting according to ASCII code?
Mybatis sort for an integer types of data when ordering how do sorting according to ASCII code?

Time:02-01

Just doing a according to the problemId (stored in the database is bigint) sorting function
Mybatis is wrote
 

The order by ${sort} ${order}


The order by ` problem_id ` asc



Then after I sort, found that was carried out in accordance with the ASCII ordering, this is obviously not, and then I went to the database and to see,
 
SELECT * FROM ` test_problem ` ORDER BY problem_id asc.

The results are normal, and not sorted according to ASCII code, then the problem will appear in the mybatis parsing,,

Then I according to the approach to baidu ${sort} a 0, after it worked, but it is clear that this will surely there is a big problem, efficiency, so how to solve this situation?

CodePudding user response:

The integer data type is: are you sure? You is that a character type, only is pure Numbers

CodePudding user response:

reference 1st floor a1767028198 response:
integer data types are you sure? You is that a character type, just is pure Numbers of

Is absolutely bigint, kid sou have no deceit

CodePudding user response:

reference 1st floor a1767028198 response:
integer data types are you sure? You is that a character type, just is pure Numbers of

If is varchar, I in the database directly sort results could not be again according to the number to row

CodePudding user response:

Mybatis won't go to adjust your order by default; If it is found that the data has changed, and see if it did what things have a plugin or aop

CodePudding user response:

reference 4 floor a1767028198 response:
mybatis won't go to adjust your order by default; If it is found that the data has changed, and see if it has a plugin or aop did what things
I set up in bootstarp_table sortable=true, to mybatis -- "${sort} is problemId fields, by the way, is it possible that is order by problemId, problem_id is supposed to be?

CodePudding user response:

Sure enough, it is the problem here,,,,
  • Related