1. Problem Prophet
- The MySQL database under the windous system is not case-sensitive.
The <query result column name> username in the database will match the <attribute name> userName attribute in the java entity class. - On the Linux operating system, the MySQL database is strictly case-sensitive, and
the above situation will not correspond
Second, the solution (find a way to correspond)
1. Alias the columns of the database
Advantages:
fast speed, high efficiency, simple, it can be solved in sql statement.
2. A configuration method is provided in Mybatis <the corresponding relationship between the column name of the configuration query result and the attribute name of the entity class>
Note: the return type becomes the above return a map map has our corresponding relationship
Disadvantage: need to parse one more xml file, the efficiency is not as high as the method
Advantage: convenient, no need to change the matching of all sql statements
Summarize
- The first method is to alias the database column names, which is simple and fast, and has great advantages for a small number of fields. When we need to change the fields, it is inconvenient for a long time.
- The second is an internal configuration method that we can use when we use the Mybatis framework.