Home 类库下载 java类库 Mybatis common summary

Mybatis common summary

Oct 29, 2016 pm 01:37 PM

1. Parameter injection
1.1 uses the form of #{0}, #{1}, 0 represents the first parameter, 1 represents the second parameter
 public List queryList(String workerId, Integer topNum);

 
1.2Map or encapsulated object, workerId is the key in the map; if it is an object, workerId For attributes in objects, this method is very commonly used
  public Integer queryCountByWorkerId(Map queryParam);
 public Integer queryCountByWorkerId(@param(“workerId”)String workerId); 

2. Return
2.1 mapping

  
  
  
 
 
  select ID,CREATE_DATE,WORKERID from tableName
 
 This way the query statement queries the fields directly It’s just a field in the database, just define the mapped column
2.2 Return the object directly
 

 The field alias returned by the query here must correspond to the attributes in the returned object


3. Execute native sql
3.1sql parameters:    //getter setter omitted

  }

3.2 interface:
  /**
  * @Function description: Create

  * @param vo

  * @return
 */

  public int excuteCreateSql(ParamVo vo);


  /**
  * @Function description: Query
  * @param vo
  * @return
 */
public List
> excuteSelectSql(ParamVo vo);

3.3xml:
 

  ${sql}
 

 ${}Do not compile sql and execute it directly. If you use #{sql}, an error may be reported
  

 ${ sql}  

  I don’t know here whether to use map or hashmap as the return type

4.include: Sometimes the fields to be returned by the two methods are the same or the where clause is the same. In order to avoid duplication of code, just extract it and use include
4.1 The same part of the definition clause
   WHERE F.STATUS = 1 AND F.WORKER_ID = #{workerId}
  ORDER BY C.CREATE_DATE DESC

 


4.2 Quote
  
   SELECT COUNT(1)
  

 
  

   SELECT ID id, WORKER_ID workerId, UPDATE_DATE updateDate,...

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)