1. in order TO use <dynamic>'s <isNotNull> and other places TO encounter unnecessary bugs, we define all types as original types when defining map or TO, such as defining INTEGER.
2. when writing a statement, it is easy to introduce difficult errors such as ":", and ":". the two characters are in. the differences in java files are obvious, but they cannot be seen by the naked eye in xml. Therefore, use punctuation in half-width English.
3. Define the type as accurately as possible for all fields that appear. Although it seems that writing or not writing can run normally in some places, this can reduce the chance of errors and reduce the worries.
4. paste an example.
TOMap:
[Html]
<ResultMap id = "userTO" class = "UserTO">
<! -- Set the correspondence between the required data table items and UserTO member variables -->
<Result column = "ID" jdbcType = "int" javaType = "java. lang. Integer" property = "id"/>
<Result column = "USERNAME" jdbcType = "varchar" javaType = "java. lang. String" property = "username"/>
<Result column = "PASSWORD" jdbcType = "varchar" javaType = "java. lang. String" property = "password"/>
<Result column = "GENDER" jdbcType = "Integer" javaType = "java. lang. Integer" property = "gender"/>
<Result column = "DATE_OF_BIRTH" jdbcType = "date" javaType = "java. util. Date" property = "dateOfBirth"/>
<Result column = "CREATED_DATE" jdbcType = "datetime" javaType = "java. util. Date" property = "createdDate"/>
<Result column = "IMAGE_ID" jdbcType = "Integer" javaType = "java. lang. Integer" property = "imageId"/>
</ResultMap>
SQL:
[Html]
<Update id = "updateUserinfoById" parameterClass = "UserTO">
Update USER
<Dynamic prepend = "set">
<IsNotNull prepend = "," property = "password"> PASSWORD = # password: VARCHAR # </isNotNull>
<IsNotNull prepend = "," property = "gender"> GENDER = # gender: INTEGER # </isNotNull>
<IsNotNull prepend = "," property = "dateOfBirth"> DATE_OF_BIRTH = # dateOfBirth: TIMESTAMP # </isNotNull>
<IsNotNull prepend = "," property = "imageId"> IMAGE_ID = # imageId: INTEGER # </isNotNull>
<IsNotNull prepend = "," property = "status"> STATUS = # status: INTEGER # </isNotNull>
</Dynamic>
Where ID = # id: INTEGER #
</Update>
TO:
[Html]
Public class UserTO implements Constant {
Private Integer id;
Private String username;
Private String password;
Private Integer gender;
Private Integer imageId;
Private Date dateOfBirth;
Private Date createdDate;
If you can, you can perform two sets of TO, one as the parameter, and the other as the return value. Here is not an example.