tk-mybatis的方法记录

转自:https://www.cnblogs.com/tsing0520/p/11932864.html

tk-mybatis的方法记录

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "t_invoice_verify_record")
public class InvoiceVerifyRecordPO extends BasePO {
 
    private Integer invoiceKeyInformationId;
 
    private String verifyParam;
 
    private Integer verifyResultCode;
 
    private String verifyResultMessage;
 
    private Date verifyDate;
 
    private Short status;
 
    private Short type;
 
    private String verifyResultJson;
 
}

  

1
2
3
Example example = new Example(InvoiceVerifyRecordPO.class);
         
example.selectProperties("verifyParam","verifyResultJson");

  

输出信息:

SELECT verify_param , verify_result_json FROM t_invoice_verify_record ;

 

 

 

1
2
3
4
5
Example example = new Example(InvoiceVerifyRecordPO.class);
     
example.selectProperties("verifyParam","verifyResultJson")
    .and()
    .andEqualTo("status",0);

  

输出信息:

==>  Preparing: SELECT verify_param , verify_result_json FROM t_invoice_verify_record WHERE ( status = ? )  

==>  Parameters: 0(Integer) 

 

 

1
2
3
4
5
6
Example example = new Example(InvoiceVerifyRecordPO.class);
     
example.selectProperties("verifyParam","verifyResultJson")
    .and()
    .andEqualTo("status",0)
    .andLike("verifyParam","%d%");

  

输出信息:

==>  Preparing: SELECT verify_param , verify_result_json FROM t_invoice_verify_record WHERE ( status = ? and verify_param like ? )  

==>  Parameters: 0(Integer), %d%(String) 

 

 

1
2
3
4
5
6
7
8
9
10
Example example = new Example(InvoiceVerifyRecordPO.class);
     
example.selectProperties("verifyParam","verifyResultJson")
    .and()
    .andEqualTo("status",0)
    .andLike("verifyParam","%d%");
 
    // 排序
    example.orderBy("status").asc()
           .orderBy("type").desc();

  

输出信息:

SELECT verify_param , verify_result_json FROM t_invoice_verify_record WHERE ( status = ? and verify_param like ? ) order by status ASC,type DESC ;

 

 

 

 

 

 

 

1
2
3
4
5
6
7
Example example = new Example(InvoiceVerifyRecordPO.class);
     
Example.Criteria criteria = example.createCriteria();
    criteria.andEqualTo("status"0)
            .andLike("verifyParam""%d%");
    example.orderBy("status").asc()
            .orderBy("verifyParam").desc();

  

 

Example example = Example.builder(InvoiceVerifyRecordPO.class)
.select("verifyParam","verifyResultJson")
.where(Sqls.custom().andEqualTo("status", 0)
.andLike("verifyParam", "%d%"))
.orderByDesc("status","type")
.build();

原文地址:https://www.cnblogs.com/wanjun-top/p/13431853.html