In Mybatis, in the query result set, the encapsulation of a single object is far from meeting the business requirements. Therefore, you can use ResultMap: If the <association/> label is not used in ResultMap, it is the sub-object result ing. You can also automatically populate the result set without having to map the attributes of the first-level objects one by one! Of course, if the <association/> label is used in ResultMap, each object field must correspond to the table field. Otherwise, the value is null or the default value is displayed! <! -- Activing ActivityResultMap --> <resultMap type = "Activity" id = "ActivityresultMap"> <result property = "id" column = "id"/> <result property = "bid" column = "bid"/> <result property = "cid" column = "cid"/> <result property = "activity_name" column = "activity_name"/> <result property = "award_rate "column =" award_rate "/> <result property =" activity_desc "column =" activity_desc "/> <result property =" activity_list_img "column = "Activity_list_img"/> <result property = "activity_detail_img" column = "activity_detail_img"/> <result property = "start_time" column = "start_time"/> <result property = "end_time "column =" end_time "/> <result property =" activity_type "column =" activity_type "/> <result property =" activity_state "column =" activity_state "/> <result property = "activity_url" column = "activity_url"/> <result property = "activity_rule" Column = "activity_rule"/> <result property = "name" column = "name"/> <result property = "award_time_astrict" column = "award_time_astrict"/> <result property =" award_start_time "column =" award_start_time "/> <result property =" award_end_time "column =" award_end_time "/> <result property =" personal_img "column =" personal_img "/> <result property = "theme_img" column = "theme_img"/> <result property = "count_join" column = "Count_join"/> <result property = "serial_num_count" column = "serial_num_count"/> <result property = "usable_count" column = "usable_count"/> <association property = "bankInfo" javaType = "BankInfo"> <result property = "bank_name" column = "bank_name"/> </association> <association property = "card" javaType = "CreditCard"> <result property = "card_name" column = "card_name"/> </association> <association property = "activi Type "javaType =" ActivityType "> <result property =" type_name "column =" type_name "/> </association> </resultMap> when inserting data, you can use the <selectKey/> label to return the generated auto-increment ID. Of course, the ID is automatically encapsulated into the ID field of the object, instead of the int type returned by your method (it had been pitted For A Long Time): MySQL is like this, and its Order attribute is "After", which indicates that the insert statement is executed first, then, after obtaining the ID value: <insert id = "saveActivity" parameterType = "Activity" keyProperty = "id" keyColumn = "id"> insert into kk_activity (bid, cid, activity_name, award_rate, activity_de SC, activities, activities, start_time, end_time, activity_type, activity_state, activity_url, activity_rule, name, rule, rule, personal_img, theme_img, count_join) values (# {bid }, # {cid}, # {activity_name}, # {award_rate}, # {activity_desc}, # {activity_list_img}, # {activity_detail_img}, # {start_time}, # {end_time }, # {activity_type}, # {activity_state}, # {activity_url },#{ Activity_rule}, # {name}, # {award_time_astrict}, # {award_start_time}, # {award_end_time}, # {personal_img}, # {theme_img}, # {count_join }) <selectKey keyProperty = "id" resultType = "java. lang. integer "order =" AFTER "> select LAST_INSERT_ID () </selectKey> </insert> in Oracle, because IDs are generated by sequance (sequence), you need to do this: order = "BEFORE", first obtain the ID value, and then insert: In Mappler. in java Abstract METHODS, if there are multiple parameters, you can use @ Param () annotation: public List <Activity> getActivityByP Age (@ Param (value = "page") UIPage page, @ Param (value = "activity") Activity); In Mapper. in xml, you can use ONGL expressions or EL expressions. Is it convenient! If you want a program to assemble the desired SQL statement and execute it by Mybatis, you can do this: interface method: public HashMap <String, object> getOrderCardInfoBySQL (@ Param (value = "excusql") String excusql); In Mapper. xml file ing: <select id = "getOrderCardInfoBySQL" resultType = "map" >$ {excusql} </select> is it easy? If you do not understand it, refer to the Mybatis document, you can leave a message for me ..