Today when I was writing Mybatis's resultMap (result mapping), I encountered a problem:
<result column="company_name " property="companyName"/>
<result property="companyName" column="company_name"/>
The company_name corresponding to column here is the field name of my database table
The companyName corresponding to property is the attribute name of my entity class
When I use the first sentence in xml to map the database query result to the attribute com disk Name of the Java entity class, the result is null, but with the second sentence, the result is mapped successfully;
Here I read the usage documentation of Mybatis on the official website. The official website uses the second way of writing, but I read some blog articles saying that the first way of writing is also correct (and it is more readable) and asked chatgpt.
But why can't I get the correct result? ? ? Can anyone help me answer this question?