Mybatis in ResultMap the column and property

 

select element has more attributes (here that use more of):

 

id: namespace unique identifier can be used to reference this statement

parameterType: will pass the fully qualified name of the class parameters of this statement or alias

resultType: this statement to return fully qualified name or alias of the expected type (Note here that the lower collection type is an aggregate of the type may comprise, per se can not be set), it is important: using resultType OR resultMap, not both use.

resultMap: resultMap external reference name, the name of the name and the ID to the external element resultMap coincide, for mapping the result to a designated entity class objects.

 

So when we know that the use of resultMap, what resultType when they use it?

 

① When to select a table, you can use resultType, under these circumstances, MyBatis will automatically create a ReusltMap behind the scenes, based on the attribute name to be mapped to the JavaBean property

② Therefore, the use resultMap, you must write the corresponding xml resultMap

③ In order to prevent the development of our mistakes, in the absence of special requirements of the situation, column names can be completely the same name and property, or when we do not have on the correspondence, the database can not match, will be capitalized value of certain parameters, lead us originally acquired lowercase parameter names, the results did not get to, given the background

Guess you like

Origin www.cnblogs.com/lingcheng7777/p/11940038.html