[MyBatis]Mapper uses $ in order by

Problem Description

In the MyBatis project, it is found in the test interface that the returned json data cannot "sortBy": "id"be order by idsorted according to the parameters passed in . The json data returned at the time is as follows:
Insert picture description here

solve

When I found the problem, I first sortBy": "id"changed it to sortBy": "sales_history.id".
But it's no use!
Insert picture description here
For the second time, it will be sortBy": "sales_history.id"changed to sortBy": "", retest.
Insert picture description here
This time, the ascending results appeared as expected .

Why is this?
Go back and check this sentence order by #{sort}, now I changed it order by ${sort}, and try again. The
Insert picture description here
result is okay .

summary

After verification:

  • MyBatis Mapper order byneeds to be used if used in$

For details, see the difference between $ and # in [MyBatis]Mapper

Guess you like

Origin blog.csdn.net/weixin_43438052/article/details/114189641