我不是忘尘 2020-02-25 20:13 采纳率: 0%
浏览 278

有没有大佬能帮我把注解形式的Mybatis代码换成XML形式的?

public interface PostMapper {
    @Select("select * from tb_posts where board_id = #{bid} order by pid desc limit #{startPos},#{pageSize}")
    /* post和user的组合查询 */
    @Results({ @Result(column = "user_id", property = "user", one = @One(select = "com.ve.mapper.AccountMapper.selectbyuid")) })
    public List<PostModel> postlist(@Param("bid") int bid,
            @Param("startPos") int startPos, @Param("pageSize") int pageSize);

    @Insert("insert into tb_posts (user_id,board_id,posttitle,posttype) values(#{user_id},#{board_id},#{posttitle},#{posttype})")
    public int newpost(PostModel pmodel);

    @Select("select @@identity")
    // 查询最新生成记录的id
    public int returnid();

    @Select("SELECT COUNT(*) FROM tb_posts where board_id = #{bid}")
    public int getpostCount(int bid);/* 某板块帖子总数 */

    @Select("select * from tb_posts where posttitle like #{search}")
    @Results({ @Result(column = "user_id", property = "user", one = @One(select = "com.ve.mapper.AccountMapper.selectbyuid")) })
    public List<PostModel> searchpost(String search);/* 帖子标题的模糊查询 */
}

  • 写回答

1条回答 默认 最新

  • 笑看烟雨红尘 2020-02-25 22:28
    关注

    把注解里的SQL语句写到XML中就可以了吧

    评论

报告相同问题?