Home > Back-end >  Mybatis return linkedhashmap disorder problem
Mybatis return linkedhashmap disorder problem

Time:11-07

Look at the execution of SQL the
==& gt; Preparing: SELECT the Description, Description_C SpecialNum from SpecialNum WHERE SpecialNum in (?,?,?,?,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ) the order by the field (SpecialNum,? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ); 
==& gt; Parameters: EG(String), EL(String), EQ(String), EP(String), EO(String), EC(String), EH(String), EW(String), EM(String), EA(String), EI(String), ET(String), EU(String), ED(String), EE(String), EK(String), EF(String), ER(String), E-(String), EB(String), EV(String), EZ(String), EN(String), ES(String), EJ(String), EX(String), EY(String), EG(String), EL(String), EQ(String), EP(String), EO(String), EC(String), EH(String), EW(String), EM(String), EA(String), EI(String), ET(String), EU(String), ED(String), EE(String), EK(String), EF(String), ER(String), E-(String), EB(String), EV(String), EZ(String), EN(String), ES(String), EJ(String), EX(String), EY(String)
<==the Columns: Description, Description_C, SpecialNum
<==Row: Multidisciplinary, interdisciplinary, E -
<==Row: Agricultural and in Sciences, Agricultural and Biological Sciences, EA
<==Row: Arts and Humanities, Arts and Humanities, EB
<==Row: Biochemistry, Genetics and Molecular Biology, Biochemistry, Genetics and Molecular Biology, EC
<==Row: Business, Management and Accounting, Business, Management and Accounting, ED
<==Row: Chemical Engineering, Chemical Engineering, EE
<==Row: Chemistry, Chemistry, EF
<==Row: Computer Science, Computer Science, EG
<==Row: Decision Sciences, Decision Sciences, EH
<==Row: Earth and Planetary Sciences, Earth and Planetary science, EI
<==Row: Economics, Econometrics and Finance, Economics, Econometrics and Finance, EJ
<==Row: Energy, Energy, EK
<==Row: Engineering, Engineering, EL
<==Row: Environmental Science, Environmental Science, EM
<==Row: Immunology and Microbiology, Immunology and Microbiology, EN
<==Row: Materials Science, Materials Science, EO
<==Row: Mathematics, Mathematics, EP
<==Row: Medicine, Medicine, EQ
<==Row: Neuroscience, Neuroscience, ER
<==Row: Nursing, Nursing, ES
<==Row: Pharmacology, Toxicology and Pharmaceutics, Pharmacology, Toxicology and pharmacy, ET
<==Row: Physics and event, Physics and Astronomy, EU
<==Row: tended, Psychology, EV
<==Row: Social Sciences, Social Sciences, EW
<==Row: Veterinary, vet, EX
<==Row: Dentistry, dental, EY
<==Row: the Health Professions, Health professional, EZ
<==Total: 27

Look at the XML
 & lt; Select id="selectSpecialNumName" resultType="Java. Util. LinkedHashMap" & gt; 
SELECT the Description, Description_C SpecialNum from SpecialNum WHERE SpecialNum in
# {item}

The order by the field (SpecialNum, & lt; The foreach collection="list" index="index" item="item" & gt;
# {item}

Why isn't the result returned the Parameters of incoming Parameters order?

CodePudding user response:

The building Lord this problem very strange...
Mybatis returns the collection order only with the results of the SQL query collection order is consistent, this question should be converted SQL result sets order you why don't you like into the consistent, it even hard for (not), the sorting is a rule.

Suggest you to query the data sorting, so that even the most simple solution meets your demand, lambda expressions fix these easily

CodePudding user response:

Should be your second foreach tag missing attribute the separator=", "
 
SELECT the Description, Description_C SpecialNum from SpecialNum
WHERE SpecialNum in (?,?,?,?,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? )
The order by the field (SpecialNum,? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? );

CodePudding user response:

Don't you think the SQL is a bit strange? The order by the field (SpecialNum,? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? )
Less parameters before a comma,

CodePudding user response:

Is ordered by your SpecialNum ah, you see: the EA, EB, EC...
  • Related