• 注解开发中一对多的运用和使用注意项


    package com.hope.dao;

    import com.hope.domain.User;
    import com.sun.xml.internal.bind.v2.model.core.ID;
    import org.apache.ibatis.annotations.*;
    import org.apache.ibatis.mapping.FetchType;

    import java.util.List;

    /**
    * @author newcityman
    * @date 2019/11/15 - 22:59
    */
    public interface IUserDao {
    /**
    * 查询所有用户的信息
    * @return
    */
    @Select(value = "select * from user")
    @Results(id = "userMap",value = {
    @Result(id = true,column ="id" ,property ="userId" ),
    @Result(column = "username" ,property = "userName"),
    @Result(column = "sex",property = "userSex"),
    @Result(column = "address",property = "userAddress"),
    @Result(column = "birthday",property = "userBirthday"),
    @Result(column = "id",property = "accounts",
    many =@Many(select = "com.hope.dao.IAccountDao.findAccountById"
    ,fetchType = FetchType.LAZY)),
    })
    public List<User> findAll();

    /**
    * 根据用户的id,查询用户
    * @param id
    * @return
    */
    @Select("select * from user where id=#{id}")
    @ResultMap(value ={"userMap"} )
    User findOne(Integer id);

    /**
    * 根据用户名模糊查询
    * @param username
    * @return
    */
    @Select("select * from user where username like #{username}")
    @ResultMap("userMap")
    List<User> findByName(String username);


    }
  • 相关阅读:
    Redis 常用命令整理
    TCP系列01—概述及协议头格式
    TCP/IP详解--TCP网络传输数据包1460MSS和1448负载
    TCP中报文段大小(MSS)、MTU
    DNS 过滤脚本
    TCP SYN Cookies – DDoS defence
    python virtualenv venv 虚拟环境
    git 命令总结
    王兴三横四纵
    获取国税门户可供下载的资源文档
  • 原文地址:https://www.cnblogs.com/newcityboy/p/11878333.html
Copyright © 2020-2023  润新知