当前位置: 首页 > 工具软件 > Dao Script > 使用案例 >

mybatis注解Dao示例

缑智敏
2023-12-01

Springboot与mybatis整合

在application.properties文件中

mybatis.type-aliases-package=com.baidu.*.dao

Dao层

@Mapper
public interface ProvMarkSuppDao {
	@Select("<script>"
            + "SELECT "
            + "sett_mmonth"
            + " FROM  dmk_cgp_pg_rpt a "
            + " WHERE  1=1 "
            + "<if test='settMonth != null '>"
            + "  and  sett_month =  #{settMonth,jdbcType=VARCHAR}  "
            + "</if>"
            + " ORDER BY sett_month  ASC "
            + "</script>")
	@Results(id="getMasterAgreeExport", value= {@Result(property = "settMonth", column = "sett_month")
	})       
	List<MasterAgreeBean> getMasterAgreeExport(
			@Param("settMonth") String settMonth
			);
}

实体bean:

@AllArgsConstructor:全部参数的构造函数
@NoArgsConstructor:无参构造函数

@Data
@AllArgsConstructor
@NoArgsConstructor
public class MasterAgreeBean {
	private String settMonth;
	private String provName;
	private String operCode;
	private String operName;
	private String channelId;
	private String dgpFees;

}
这样就不用写mapping.xml



 类似资料: