How to write Mybatis

the first one: write in java.
@ Select ("select bureau_code from drt_opr_area")
List < String > getAllAreas ();
the second: write in xml.
< select id= "selectList" resultMap= "BaseResultMap" parameterType= "com.csg.intshop.entity.DrtShopConfig" >

    select 
    <include refid="BaseColumnList" />
    from drt_shop_config
    where 1=1
    <include refid="BaseCustomQueryCondition" />
  </select>

I would like to ask: under what circumstances is it good to write java code, and under what circumstances do you choose to write xml? If it is a full table query, is there any difference in performance between the two writing methods?
for example: when there are many table fields, the full table query writing xml looks concise and readable. -sharp-sharp-sharp problem description

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Mar.28,2021

Hello. Generally speaking, normal projects are easy to maintain using xml,. For performance, you should use the form of xml or after annotated sql, because xml, is also officially recommended and the function of stitching dynamic sql is limited. For projects, sql and java (project programming language) should be distinguished and should not be mixed together, and splicing sql is easy to explode. Xml is what I support and recommend, for post-maintenance and upgrade versions, but simple and easy projects can also be done with sql.


Hello. 1. Add object return self-increment primary key. Multiple select queries (> = 3) appear in a Mapper interface, and each query needs to write the same return @ Results content (this part is usually a lot of content). In this case, in order to make the Mapper interface cleaner and less repetitive code, we will write the specific implementation of these select methods in the xml file. Because at the top of the xml file we will configure and comment
2, that is, dynamic splicing of sql through annotations is not as convenient as xml


is better than separate, xml is better.
unless it's a development like Spring data jpa rest

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b9cf2c-2f35d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b9cf2c-2f35d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?