2022
01-22
01-22
Mybatis日期格式自动转换需要用到的两个注解说明
Mybatis日期格式自动转换publicclassStudent{publicIntegerid;publicStringstudentName;@JsonFormat(pattern="yyyy-MM-dd")//从数据库读出日期格式时,进行转换的规则@DateTimeFormat(pattern="yyyy-MM-dd")//接受从前端传入的日期格式,映射到java类日期属性的规则publicDatebirth;publicIntegergetId(){returnid;}publicvoidsetId(Integerid){this.id...
继续阅读 >
mybatis注解实现一对多关联查询@Select("selectid,mockexam_sectionassection,idassectionId"+"fromt_p_qb_mockexam_section"+"wheremockexam_charpter_id=#{charpterId}andis_delete=0"+"orderbymockexam_section_idxasc")@Results({@Result(property="questionList",column="sectionId",many=@Many(select="com.zikaoshu.baseinfo.mapper.BaseinfoQuestionMapper.listQuestionResDto"))...
目录使用注解开发使用注解完成CRUD使用注解开发本质:反射机制实现底层:动态代理1、注解在接口上的实现publicinterfaceUserMapper{@Select("select*fromuser")List<User>getUsers();}2、使用注解时,需要在核心配置文件中绑定接口<mappers><mapperclass="com.xiao.dao.UserMapper"/></mappers>3、测试使用publicclassUserMapperTest{@Testpublicvoidtest(){SqlSessionsqlSess...